My previous post on
interfaces has generated quite a few comments:
I prefer to rely on API versionning than to have I*2 for additional
methods in an interface.
This is the sure way to DLL hell… Not sure I want to go there.
Anyway as a client to something (not an implementor) I don’t really care
if CoffeyMaker is a class or an interface…
I still find it important to know whether I can "new" a type or if I should
look up a factory to create it.
Some argued that using ‘I’ adds noise. Usage of ‘Impl’ suffix takes care
of this problem too.
I wonder if the author of this remark noticed the irony of this comment
Adding numbers to an existing interface is a sure sign of bad design.
It’s a bad design that sure seems to work fine for Microsoft and Eclipse, who
have a pretty good track record of producing excellent backward compatibility.
Maybe there’s something to learn from that?
What happens when you get to I*4 or I*5? Who the hell even knows?
You answered your own question:: you name them 4, 5, etc…
More seriously, I have to say I have rarely seen any interface past the
number 3, which makes me think that the I*2 convention is a stopgap measure for
the first or second generation of your interface, but that after this, the
interface is usually stable enough to be left alone (or new functionalities are
added in interfaces that receive a brand new name).
That is, you don’t start programming to an interface unless you’re
totally sure that the interface is needed.
You know, this made me realize that it’s a pretty good example why the XP
principles are contradictory. It seems to me that programming to
interfaces makes testing easier, and making testing easy is one of the main
goals of XP, therefore, you should use interfaces as much as possible. But
then, you are no longer doing the "simplest thing that could possibly work".
Cedric, can you offer your opinion on this w/ regard to Generics?
I would love to but I don’t have one yet I need to think about it
more. But you make a good point: none of these techniques take Generics
into account and I am curious to see how much of what we know on this topic will
have to be revisited.