I have always been a bit unsure of which methods to override for the different verbs/methods, always considering it a bit of a nuisance and a potential put-off for new adopters (I'm carrying on about the potential problems to new restlet implementors, but it's only because I believe it's one of the factors needed to become a successful framework). But looking at this discussion, I've started wondering if this isn't a problem in the design of Resources. I have found myself having to look at the code several times when implementing a new Resource, just to make sure I know what the class I'm extending (usually Resources, although I sometimes make my own "base" resources for applications and inherit from them) is actually doing.
According to Java Practices web site, this is one of the points for considering composition instead of subclassing [1]. I still don't know if this explicitly relates to this problem, but it definetly seems like we have a case of coupling of the implementation of Resource and its subclasses. I don't know if I'm off the map here, but just had a thought and wanted to share with the people with the know-how. Regards, Kyrre [1]http://www.javapractices.com/Topic72.cjp --- Tim Peierls <[EMAIL PROTECTED]> wrote: > On 10/11/07, Chuck Hinson <[EMAIL PROTECTED]> > wrote: > > > > allowPut(), allowPost(), allowDelete(), allowGet() > > > > handlePut(), handlePost(), handleDelete(), > handleGet() > > > > put(), post(), delete(), getRepresentation() - eh? > what? > > > > The lack of symmetry there is jarring - it leads > people to go looking > > for the get() method and when they can't find it, > they're confused. > > > It depends on how they approach the documentation. > The javadoc class comment > for Resource presents these in the reverse order; it > isn't jarring if you > first encounter getVariants, getRepresentation, put, > post, and delete, > *then* find out that there is a lower level of > handle* methods (that you > might not have to deal with at all, if you're > lucky). > > It *is* slightly awkward that you have to use the > lower level allow* methods > to control whether your higher-level overrides will > be used. Maybe the > constructor could take an argument to handle some > common cases with, say, an > EnumSet? > > > I think two things need to happen. First, the > documentation for > > handlePut(), handlePost(), handleDelete() and > handleGet() needs a > > whole lot more detail making it plain what exactly > they do. > > > More precisely, what they do by default (i.e., > implement the higher-level > API of getVariants, getRepresentation, post, put, > delete) *and* what they > should do if overridden, e.g., a warning that > overriding handleGet without > calling super.handleGet can cause any overridden > getRepresentation and > getVariants methods to be ignored (unless your > handleGet calls > getPreferredRepresentation, say). > > > And second, yes, I think put(), post() and delete() > and > > getRepresentation() need to be renamed. While > doPut(), doPost(), > > doDelete() and doGet() are OK, I think I'd prefer > processPut(), > > processPost(), processDelete() and processGet() - > but anything that > > makes it clear that they are at the same level of > processing is fine. > > > There's a false parallel here that I don't think > should be encouraged by > providing parallel names. getRepresentation takes a > Variant argument, > handleGet does not; post takes a Representation > argument, handlePost does > not. If anything, I'd argue for names that were > *less* parallel, e.g., add > instead of post, and remove instead of delete. > > Resource is the place where the uniform interface > hits the rich interface of > your domain objects. It's entirely appropriate (and > convenient!) to have an > intermediate API (getVariant, getRepresentation, > put, post, and delete) to > help ease the transition between them. > > --tim > ------------------------------------------------------------ Kyrre Kristiansen ___________________________________________________________ Yahoo! Answers - Got a question? Someone out there knows the answer. Try it now. http://uk.answers.yahoo.com/