Designing Classes for Extension

08 Dec

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.

Programming Ideas With Jake


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.

Prohibiting Inheritance

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

Leave a comment

Posted by on December 8, 2014 in Uncategorized


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: