You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@zookeeper.apache.org by "Patrick Hunt (JIRA)" <ji...@apache.org> on 2008/08/06 23:06:44 UTC

[jira] Created: (ZOOKEEPER-113) ZooKeeper.java should be interface not concrete class.

ZooKeeper.java should be interface not concrete class.
------------------------------------------------------

                 Key: ZOOKEEPER-113
                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-113
             Project: Zookeeper
          Issue Type: Improvement
          Components: java client
            Reporter: Patrick Hunt


I think ZooKeeper class in src/java/main should be an interface rather than a concrete class. Among other OO goodness this would give us more flexibility when implementing tests on client code. Would also require something like a factory to be created, which might actually work well with another JIRA we have which is the idea to use a URI(s) rather than a host:port combination when creating zookeeper clients.

Unfortunately this would have a big impact on clients as it's not b/w compatible (instantiating a new client that is).


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-113) ZooKeeper.java should be interface not concrete class.

Posted by "Doug Cutting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12621066#action_12621066 ] 

Doug Cutting commented on ZOOKEEPER-113:
----------------------------------------

Interfaces are hard to evolve back-compatibly.  So if there's a chance that user-code might implement this, it will be impossible to change without breaking that user code.  Thus I generally discourage interfaces in public APIs when back-compatible releases are a project goal (which they ought to be, if you want to retain users).

> ZooKeeper.java should be interface not concrete class.
> ------------------------------------------------------
>
>                 Key: ZOOKEEPER-113
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-113
>             Project: Zookeeper
>          Issue Type: Improvement
>          Components: java client
>            Reporter: Patrick Hunt
>
> I think ZooKeeper class in src/java/main should be an interface rather than a concrete class. Among other OO goodness this would give us more flexibility when implementing tests on client code. Would also require something like a factory to be created, which might actually work well with another JIRA we have which is the idea to use a URI(s) rather than a host:port combination when creating zookeeper clients.
> Unfortunately this would have a big impact on clients as it's not b/w compatible (instantiating a new client that is).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-113) ZooKeeper.java should be interface not concrete class.

Posted by "Benjamin Reed (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12621497#action_12621497 ] 

Benjamin Reed commented on ZOOKEEPER-113:
-----------------------------------------

I don't think moving to an interface would help you have a pluggable ClientCnxn class. You still want all the logic for the sync and async code as well as the event threads from the ZooKeeper class. Making ClientCnxn an interface would be a reasonable thing to do once we have another implementation of the ClientCnxn.

> ZooKeeper.java should be interface not concrete class.
> ------------------------------------------------------
>
>                 Key: ZOOKEEPER-113
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-113
>             Project: Zookeeper
>          Issue Type: Improvement
>          Components: java client
>            Reporter: Patrick Hunt
>
> I think ZooKeeper class in src/java/main should be an interface rather than a concrete class. Among other OO goodness this would give us more flexibility when implementing tests on client code. Would also require something like a factory to be created, which might actually work well with another JIRA we have which is the idea to use a URI(s) rather than a host:port combination when creating zookeeper clients.
> Unfortunately this would have a big impact on clients as it's not b/w compatible (instantiating a new client that is).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-113) ZooKeeper.java should be interface not concrete class.

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12621056#action_12621056 ] 

Patrick Hunt commented on ZOOKEEPER-113:
----------------------------------------

A stub was my second choice. ;-)

Honestly I don't see how calling a factory method is any more inconvenient for a user than calling a constructor, you get a ZooKeeper instance back in any case. I would say an interface is _more_ convenient for the user in the following respects:

1) the interface provides a specific place to define, document and monitor the contract
2) factories are very common constructs, esp as we are considering use of URI to specify cluster, users know what they are
3) factories allow separation of "how to construct" from "how to use".
4) in some(limited) sense "what's good for implementors is good for users", separating interface from implementation usually results in better code... (granted not always true)

> ZooKeeper.java should be interface not concrete class.
> ------------------------------------------------------
>
>                 Key: ZOOKEEPER-113
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-113
>             Project: Zookeeper
>          Issue Type: Improvement
>          Components: java client
>            Reporter: Patrick Hunt
>
> I think ZooKeeper class in src/java/main should be an interface rather than a concrete class. Among other OO goodness this would give us more flexibility when implementing tests on client code. Would also require something like a factory to be created, which might actually work well with another JIRA we have which is the idea to use a URI(s) rather than a host:port combination when creating zookeeper clients.
> Unfortunately this would have a big impact on clients as it's not b/w compatible (instantiating a new client that is).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (ZOOKEEPER-113) ZooKeeper.java should be interface not concrete class.

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/ZOOKEEPER-113?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Hunt resolved ZOOKEEPER-113.
------------------------------------

    Resolution: Invalid

Closing this as invalid since no one seemed to agree with me. :-(

> ZooKeeper.java should be interface not concrete class.
> ------------------------------------------------------
>
>                 Key: ZOOKEEPER-113
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-113
>             Project: Zookeeper
>          Issue Type: Improvement
>          Components: java client
>            Reporter: Patrick Hunt
>
> I think ZooKeeper class in src/java/main should be an interface rather than a concrete class. Among other OO goodness this would give us more flexibility when implementing tests on client code. Would also require something like a factory to be created, which might actually work well with another JIRA we have which is the idea to use a URI(s) rather than a host:port combination when creating zookeeper clients.
> Unfortunately this would have a big impact on clients as it's not b/w compatible (instantiating a new client that is).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-113) ZooKeeper.java should be interface not concrete class.

Posted by "Benjamin Reed (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12620632#action_12620632 ] 

Benjamin Reed commented on ZOOKEEPER-113:
-----------------------------------------

-1 This is the kind of change that makes things more convenient for the implementors, but less convenient for the users. Since there are many more users than implementors I don't think it is a good trade off to make.

I would like to propose instead that we do a ZooKeeperStub class that extends ZooKeeper that we can use for testing. It can have all the methods stubbed out so that we could override methods easily.

> ZooKeeper.java should be interface not concrete class.
> ------------------------------------------------------
>
>                 Key: ZOOKEEPER-113
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-113
>             Project: Zookeeper
>          Issue Type: Improvement
>          Components: java client
>            Reporter: Patrick Hunt
>
> I think ZooKeeper class in src/java/main should be an interface rather than a concrete class. Among other OO goodness this would give us more flexibility when implementing tests on client code. Would also require something like a factory to be created, which might actually work well with another JIRA we have which is the idea to use a URI(s) rather than a host:port combination when creating zookeeper clients.
> Unfortunately this would have a big impact on clients as it's not b/w compatible (instantiating a new client that is).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (ZOOKEEPER-113) ZooKeeper.java should be interface not concrete class.

Posted by "Patrick Hunt (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/ZOOKEEPER-113?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12621088#action_12621088 ] 

Patrick Hunt commented on ZOOKEEPER-113:
----------------------------------------

That's a good point Doug, not sure if it's an issue in this case though. I don't think we expect users to implement this themselves... anything is possible though since we don't specify final.

What got me thinking about this (in addition to the URI idea) is that ZooKeeper.java already separates out the message send/recv into a ClientCnxn class. If we wanted to have alternate implementations of ClientCnxn (say one based on mina/grizzly/blockingio or perhaps some messaging bus architecture) our only reasonable option currently would be to create ZooKeeper subclasses similar to the comment Ben made originally on this jira (e.g. ZooKeeperMina.java). Other options such as passing cnxn in the constructor to ZK, or specifying a connection "type" in the constructor are also possible but seem less appealing to me.


> ZooKeeper.java should be interface not concrete class.
> ------------------------------------------------------
>
>                 Key: ZOOKEEPER-113
>                 URL: https://issues.apache.org/jira/browse/ZOOKEEPER-113
>             Project: Zookeeper
>          Issue Type: Improvement
>          Components: java client
>            Reporter: Patrick Hunt
>
> I think ZooKeeper class in src/java/main should be an interface rather than a concrete class. Among other OO goodness this would give us more flexibility when implementing tests on client code. Would also require something like a factory to be created, which might actually work well with another JIRA we have which is the idea to use a URI(s) rather than a host:port combination when creating zookeeper clients.
> Unfortunately this would have a big impact on clients as it's not b/w compatible (instantiating a new client that is).

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.