-
Notifications
You must be signed in to change notification settings - Fork 1
Class Structure
Alex Aubé edited this page Apr 22, 2015
·
2 revisions
- Clean needs to be well organized inside classes
- Classes must have proper package and namespace structure
- Constants (private final static)
- Static private attributes
- Private attributes(members)
- Public methods => Or logically linked group of methods
- Private methods that they use
- Other public methods or group...
- We aim to read the class just like we would a newspaper
- Sometimes getters/setters go to the end to avoid extra noise
- No public attributes => rare exceptions
- Prefer private attributes
- There are times where we need to compromise
- Be weary of protected attributes
- Class should be small
- It should be even smaller
- It is not measured in terms of LOC(lines of code), rather in terms of responsibilities. Should respect Single Responsibility Principle(SRP)
Maximize in namespaces and packages
- Never put classes in a default package
- Proper to the language
- Considers business model, glossary, etc..
- They do not mean the same thing to everybody
- What looks alike sticks together
- Think about dependencies
- Think about code reuse
- Logical arborescence
- Should be separated in sub-packages