Design and document for inheritance else prohibit it
When we are designing a class if it is only for internal use and not for extension then we should make the class final. The effective java book has clearly mentioned this line.
The interaction of inherited classes with their parents can be surprising and unpredictable if the paren class wasn’t designed to be inherited from.
Classes should be two kinds :
- Classes designed to be extended, and with enough documentation to describe how it should be done
- Classes marked final