|
|
Re: Should I create an interface if I have only one implementation?
|
Posted: Nov 4, 2005 11:13 AM
|
|
responding-> > I want to approach from a different perspective. I am in > favor of not bringing any complexity until you need it. > The staffing and the nature of the software that you are > designing are crucially important when making decisions > about interfaces-all-the-way, or interfaces-when-you-need > kind of approaches.
I disagree. I think this is just related to "better practices" in software development.
> But if you are developing a custom tailored software for > one and only one company to use, and the staff in the > company are not very experienced in OO/Java, you have to > think twice before making the architecture complicated by > introducing overly used interfaces and factory/locators to > find the only instance ever of a class in a system. Plus > imaging the developers will have to understand and make > modifications to the system down the road.
You must not forgt that we dont make softwares for "our own" consumption. Every enterprise follows some standard in developing any software , to be or not to be used, in-house. You just cant go about start coding and expect user or developer to know the things.
> I also believe that a class carries an interface with its > public methods. And today's IDEs make it very easy to > refactor when you want to change an existing class. And > having interfaces does not mean that you won't need to > change your system all over the place. You won't need to > change your system ONLY IF you can come up with a generic > interface, otherwise the effort will be the same with or > without the interfaces.
Why do you forget, that interface is design while classes provides implementation of design !!
> Here is an example: I am building custom software for a > company that is doing business only in US, and I need to > deal with Addresses. Should I create only one Address > class that has street, city, state and zip codes? Or > alternatively should I careate an Address interface, > Address class, and a factory/locator. if you choose > interfaces, your interface will most likely have some > methods to deal with state and zip codes. > Now, say that the company got bigger, and they now want to > support Canada and Mexico addresses. Can u tell me how > helpful it was that you chose interfaces? I can see that > your whole interface is changing dramatically, because > state and zip code stuff are different in other countries. > So I believe choosing interface would be 'immature', and > the complexity introduced would not bring any benefit down > the road based on the scenario above.
You are missing my point. Design and implementation are concerns of different people. Designer needs to work in his place to work out future/ current strategies. While developers work gets easy because of better IDE, designers not, because of changing senarios as mentioned by you.
regards, Shashank
|
|