This guy has a lot of good advice. I see many cases of code on the web that could be vastly improved by implementing his methods.
In Effective Java by Joshua Bloch, it is explained that if you create a class, you should “design and document for inheritance or else prohibit it” (item 17). It gives some very good advice about making classes to be extended, but I always felt it lacking in patterns for doing so. I highly recommend Effective Java to any Java programmer, as it has good tips for just about every level of Java programmer (other than maybe a super expert).
I would dig into the tips that he provides, but that would be invading on his great work, and it would probably make my article too long for my liking.
One of the first things you should do when designing a class to be inherited from is to figure out what you don’t want subclasses to change or have access to. If you’re fairly certain that you…
View original post 1,078 more words