samedi 18 avril 2020

access other class' members naturally without getters/setters

"tell, don't ask" principle is useful to eliminate unnecessary getters/setters, but it has limitations.

For example, assume that we develop simple physics engine.

Then it is naturally that the collision resolver "asks" physical properties of physical objects rather than it "tells" them to do something.

But we still hope avoiding getters/setters in above situations, since they break out encapsulation.

How can we design while meeting two requirements-natural and no getters/setters?

Aucun commentaire:

Enregistrer un commentaire