Interfaces considered Important.
Coding Conventions - _I_ want to kill the Impl.
<Snip>
What I do know, however, is that classes are the principle objects in Java, not interfaces. Interfaces are handy, dandy and cool, but they're there to help structure your classes and allow interoperation without multiple inheritance, NOT to be the prime way of programming. If you're thinking "I'll just program to interfaces and forget about those classes", you need to come up to speed because I think that fad went out a couple years ago.
-Russ [Russell Beattie Notebook]
This is interesting, mostly because I used to agree, and now disagree (sorry Russ). I think interfaces are one of the most under-used and useful parts of Java. I certainly believe that if you do have a class and an interface that it implements, the interface gets priority, ie. the unadorned name of the thing. <snip>
[Pushing the envelope]
Simple example: List myList = new ArrayList();
Do I care what class 'myList' is? No, not at all. So here, programming to interfaces is totally legitimate. If in a round of performance optimisation someone wants to go and change the class used they can (as long as the test suite still works, of course ;) )
However, I'm by no means an 'everything must be interface / implementation separated' kind of guy. I personally think that interfaces should appear out of refactoring (normally - if you're making a public API then that might be a different matter, but I'm not going to try and think about 'test-first APIs' here!)
Regarding naming though, I hate calling things 'Ifoo', and I'm kind of inbetween about whether 'FooImpl' is a great thing. If you are only producing Interfaces out of refactoring there's probably going to be more that one implementation anyway, so calling it just plain 'FooImpl' isn't a great idea since that implies that there's only one significant implementation.
2:35:02 PM
|
|