Extreme Advice 2: Provide an Interface for every base class

I heard this one while working for a consulting company. The idea is that you write your base class, create an interface out of it (this is quite easy with todays refactoring tools) and then use the interface where possible instead of the base class.

This might look like an overhead to some of your colleagues but it will pay off in the end! I must say I don’t follow this though in day to day coding (there I do it when necessary), but it’s definitely worth doing in frameworks. It will come in very handy for people that need to provide a different implementation or if you need to implement your interface on a class that already inherits from somewhere else. I ran into this problem so many times and it is really hard to solve later on in a framework situation.

One thought on “Extreme Advice 2: Provide an Interface for every base class

Leave a Reply to Marc Vangrieken Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>