This function exposes the value of worldSize, so it is a form of representation exposure:
/**
* Returns the size of the simulation world.
* Used for documentation ONLY
* Should not have representation exposure
*
* @return The size of the simulation world.
*/
public int getWorldSize()
{
int clone = this.worldSize;
return clone;
}
I have multiple of these functions in a project, and am only using them for documentation. I am wondering if its possible to obtain the same result without exposing the values of the integers directly.
I have used .clone() or Arrays.copyOf() in the past, but both of those are not for int type functions.
New contributor
Florian is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1