English
Summary
Conclusions
A class defines a validated way to create and change state. Constructors ensure consistent initial data, properties separate access from storage, and visibility modifiers restrict where changes can occur. Packages organize names; nested types express a local relationship. A model's quality is determined by its contract and checks, not by the number of classes written.
Self-check questions
- Why does
valnot guarantee object immutability? - How does a constructor parameter differ from a property?
- In what order do
initand a secondary constructor execute? - Why must an initial value be checked separately from the setter?
- When is
fieldneeded, and when is a field unnecessary? - What risk does reading an uninitialized
lateinitcreate? - How does a module differ from a package?
- When should a nested class be
inner? - What should be checked after a method fails?
- How will the class look in UML and to a Java client?