Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Passing IDs instead of entire objects is not an Object-Oriented approach #10
The tool is a discrete event simulator that relies on message passing to execute simulation tasks.
Detailed information about how the feature should work
The SimEntity.send method, which is used by several sub-classes, receives an Object data parameter, that usually is an array of entities' IDs. The DatacenterSimple.processVmCreate method is an example of this problem, where the parameter is filled with the Datacenter ID, the VM id and a last integer to represent a boolean value.
Considering that the method send is used to pass several and totally different kind of data for different entities, it should be tried to pass a specific object with everything that is needed, instead of an int array. This object shouldn't just store these IDs into different attributes, but instead, store the objects that these IDs represent.
The problem of using IDs to create relationships happens in other contexts, such as to relate a Cloudlet to the Vm that will run it and the broker that represents the Cloudlet customer, it is used a set of IDs, respectively, vmId and brokerId, instead of a Vm and DatacenterBroker attributes.
Some attributes that have to be changed from int to a specific object (the default value has to be set using the NULL object pattern)
A brief explanation of why you think this feature is useful
The proposal improves the OO design, makes the code type-safe and clear to understand and tries to avoid runtime cast exceptions.
Passing an entire object doesn't increase memory footprint once it is passed just a reference to an already instantiated object.
After all, creating true OO relationships using objects instead of IDs, allows you to navigate through the entities to get the data that you want. For instance, to know what is the Datacenter where a cloudlet is running would be possible just by calling