initial Class design: access modifiers and no-arg constructors

Posted by yas on Programmers See other posts from Programmers or by yas
Published on 2012-05-10T19:18:41Z Indexed on 2012/06/27 9:22 UTC
Read the original article Hit count: 238

Filed under:
|
|
|

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?

© Programmers or respective owner

Related posts about java

Related posts about design