- Declare the class as a final so it can’t be extended.
- Make all fields private so that direct access will be avoided.
- Do not implement setter methods for a variables.
- Make all mutable fields final so that it’s value can be assigned only once.
- Perform cloning of objects in getter methods for returning the copy rather than returning the actual object reference.







Leave a comment