Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert the static methods and attributes in CloudSim class to instance methods and attributes #38

manoelcampos opened this issue Nov 24, 2016 · 0 comments


Copy link

manoelcampos commented Nov 24, 2016


CloudSim class is used just in a static context, since all its methods and attributes are static. By this way, the class stores data related to a particular simulation being run, what makes impossible to run multiple simulations in parallel.

Using CloudSim instances will provide a complete isolation between simulations being executed in parallel.

The use of static methods also makes very difficult to test classes that depend on CloudSim class.
Mocking a static method can just be performed using libraries such as PowerMock, that introduces more complexity to test writing.

Detailed information about how the feature should work

The static elements in CloudSim class have to be converted to instance elements and the class has to provide public constructors to be used to initialise the simulation, instead of calling a static init method.

An example scenario where this feature should be used

It will allow running several simulations in parallel, avoiding that a simulation interfere in the results of other ones.

It will also make much easier to write unit tests for classes that depend on CloudSim, since a simple library such as EasyMock, that is already being used, can create mock objects without a large increase in tests complexity.

A brief explanation of why you think this feature is useful

It will take one step further in moving away from CloudSim issues and paving the way to provide a highly extensible and maintainable framework.

It will allow writing more and meaningful tests to increase framework accuracy and provides the base for inclusion of upcoming features.

Included Examples

  • All existing examples now use this new feature. They just instantiate a CloudSim object using a no-args constructor to initialize the simulation. The most basic example is the BasicFirstExample.
  • The ParallelSimulationsExample is one that shows how it is straightforward to run simulations in parallel using Java 8 Streams and Lambda Expressions features.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

1 participant