commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jeff Dever <jsde...@sympatico.ca>
Subject [httpclient] Is the HttpMethod interface a "Good Thing"?
Date Thu, 05 Sep 2002 19:03:32 GMT
One of the core objects in HttpClient is the HttpMethod interface.  A
base implementation of this interface is provided by
the HttpMethodBase class.  The HTTP methods (such as PostMethod,
GetMethod ...) are then specialized by extending
HttpMethodBase.  HttpMethod is used as the identifier for the generic
handling of HTTP methods.

What is the benefit to having an interface and then a base
implemenntation that derived classes are supposed to extend?
Why not just do away with the interface, and rename HttpMethodBase to be
HttpMethod?

The current interface + base implementation leads to maintaince
problems, particularly for a library.  For example, if I
want to add a new function to HttpMethod, I have to declare it in the
interface, and then provide a default
implementation in the HttpMethodBase class.  Thats all well and good,
but for any client that has implemented the
HttpMethod interface directly, their code would break.

But if there was just a base implementation, I would just add the
function once,  (comment it once) and provide a default
implementation.  Any derived classes would still work fine, but would
have this new method available with the default
implementation from the base class.

I can see a interface being useful if you wanted an object to be to
things at one time (like a Map and a List), but I can't see
this being at all useful in HttpMethod.

I would like to consider removing the interface, and renaming
HttpMethodBase to HttpMethod for the 2.0 release.  This
would only effect users that actually implemented HttpMethod rather than
extended HttpMethodBase.  As there is 2000
lines of rfc2616-implementing-code in HttpMethodBase, I would think that
few (if any) clients would actually have done
this.

Comments?


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message