cloudsimplus / cloudsimplus

State-of-the-art Framework 🏗 for Cloud Computing ⛅️ Simulation: a modern, full-featured, easier-to-use, highly extensible 🧩, faster 🚀 and more accurate ☕️ Java 17+ tool for cloud computing research 🎓. Examples: https://github.com/cloudsimplus/cloudsimplus-examples

Home Page:https://cloudsimplus.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

manoelcampos opened this issue · comments

FEATURE:

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.