initial Class design: access modifiers and no-arg constructors
- by yas
Context:
Student working through Class design in personal/side project for Summer. I've never written anything implemented by others or had to maintain code. Trying to maximize encapsulation and imagining what would make code easy to maintain.
Concept:
Tight/Loose Class design where Tight and Loose refer to access modifiers and constructors.
Tight: initially, everything, including setters, is private and a no-arg constructor is not provided (only a full constructor).
Loose: not Tight
Exceptions: the obvious like toString
Reasoning:
If code, at the very beginning, is tight, then it should be guaranteed that changes, with respect to access/creation, should never damage existing implementations. The loosening of code happens incrementally and must be thought through, justified, and safe (validated).
Benefit:
Existing implementing code should not break if changes are made later.
Cost:
Takes more time to create.
Since this is my own thinking, I hope to get feedback as to whether I should push to work this way. Good idea or bad idea?