You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by Thomas Koch <th...@koch.ro> on 2011/09/23 10:16:27 UTC

Get rid of unnecessary Interfaces

Hi,

there are some interfaces in the ZK code that have only one implementation. I 
propose to get rid of the interfaces and use the classes directly:

org.apache.zookeeper.server.Stats
org.apache.zookeeper.server.persistence.SnapShot
org.apache.zookeeper.server.persistence.TxnLog

There are other interfaces, named *Bean, which seem to be necessary, but I 
don't know about beans.

Rationale:
http://www.symphonious.net/2011/06/18/the-single-implementation-fallacy/
http://rrees.wordpress.com/2009/01/31/programming-to-interfaces-anti-pattern/

tl;dr:
- Browsing the code gets harder since the IDE always jumps to the interface, 
instead of to the implementation.
- Changing the method signatures involves changing the interface and the 
class.
- There are more things in the code base to confuse you.

May I fill an issue and upload a patch?

Regards,

Thomas Koch, http://www.koch.ro

Re: Get rid of unnecessary Interfaces

Posted by Patrick Hunt <ph...@apache.org>.
On Fri, Sep 23, 2011 at 7:10 AM, Benjamin Reed <br...@apache.org> wrote:
> i believe the beans are used for jmx.

That's correct. (If you're looking for things to work on JMX has had
some interest/comments recently, in particular improving the object
naming comes to mind, but there were other comments for improvements
that seemed reasonable to add/change).

Patrick

Re: Get rid of unnecessary Interfaces

Posted by Benjamin Reed <br...@apache.org>.
that's right tom. many of those interfaces were put in by design so
that later we can have other implementations, some of them were not
there originally. i agree thomas that it is a pain that you have to do
two clicks in eclipse to get to the actual implementation.

i believe the beans are used for jmx.

ben

On Fri, Sep 23, 2011 at 2:31 AM, Tom Klonikowski <me...@kloni.de> wrote:
> Hi Thomas,
>
> just because there's only one implementation doesn't mean they're
> unnecessary. Think about implementations yet to come - e.g. imagine
> storing a snapshot into some kind of distributed fs or memory.
>
> I think those interfaces exist by design.
>
> Regards,
>
> Tom
>
> Am 23.09.2011 10:16, schrieb Thomas Koch:
>> Hi,
>>
>> there are some interfaces in the ZK code that have only one implementation. I
>> propose to get rid of the interfaces and use the classes directly:
>>
>> org.apache.zookeeper.server.Stats
>> org.apache.zookeeper.server.persistence.SnapShot
>> org.apache.zookeeper.server.persistence.TxnLog
>>
>> There are other interfaces, named *Bean, which seem to be necessary, but I
>> don't know about beans.
>>
>> Rationale:
>> http://www.symphonious.net/2011/06/18/the-single-implementation-fallacy/
>> http://rrees.wordpress.com/2009/01/31/programming-to-interfaces-anti-pattern/
>>
>> tl;dr:
>> - Browsing the code gets harder since the IDE always jumps to the interface,
>> instead of to the implementation.
>> - Changing the method signatures involves changing the interface and the
>> class.
>> - There are more things in the code base to confuse you.
>>
>> May I fill an issue and upload a patch?
>>
>> Regards,
>>
>> Thomas Koch, http://www.koch.ro
>
>

Re: Get rid of unnecessary Interfaces

Posted by Tom Klonikowski <me...@kloni.de>.
Hi Thomas,

just because there's only one implementation doesn't mean they're
unnecessary. Think about implementations yet to come - e.g. imagine
storing a snapshot into some kind of distributed fs or memory.

I think those interfaces exist by design.

Regards,

Tom

Am 23.09.2011 10:16, schrieb Thomas Koch:
> Hi,
> 
> there are some interfaces in the ZK code that have only one implementation. I 
> propose to get rid of the interfaces and use the classes directly:
> 
> org.apache.zookeeper.server.Stats
> org.apache.zookeeper.server.persistence.SnapShot
> org.apache.zookeeper.server.persistence.TxnLog
> 
> There are other interfaces, named *Bean, which seem to be necessary, but I 
> don't know about beans.
> 
> Rationale:
> http://www.symphonious.net/2011/06/18/the-single-implementation-fallacy/
> http://rrees.wordpress.com/2009/01/31/programming-to-interfaces-anti-pattern/
> 
> tl;dr:
> - Browsing the code gets harder since the IDE always jumps to the interface, 
> instead of to the implementation.
> - Changing the method signatures involves changing the interface and the 
> class.
> - There are more things in the code base to confuse you.
> 
> May I fill an issue and upload a patch?
> 
> Regards,
> 
> Thomas Koch, http://www.koch.ro