-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Alternate HTTPObjects creation API #15
Comments
Sorry @ratamacue, I would have responded earlier but I just now noticed this. FWIW, @chrisalbright and @SeanShubin have recently shared similar thoughts to this. I think what people are feeling is the 'nouniness' of the api. To help respond/explain this aspect of the design, I've started work on a nouniness article. To further elaborate, I think the core idea with the whole API in this regard is encapsulation of the behavior for a given URL. This is where the 'object' part of the 'httpobjects' name is unfortunate; I've always been concerned that it may give people the impression that object-orientation is the core concept here, when the real focus is on the encapsulation of URL + methods. This is my main point of departure from the more 'verby' APIs out there. That said, there are times when the relationship between the URL and it's functionality is so generic that falling back to simple function composition (which still maintains the encapsulation) is appropriate, and it would be nice to make that easier. Another aspect of the API worth considering is that it takes the "many resources, n verbs" part of the API seriously. So, my main concerns are that:
Option 1: compose()Adding a 'compose' function that facilitates the style that I think you're shooting for. @chrisalbright, Matt Bague & I were playing with this the other day and came up with a scala signature that was something like this:
which you'd be able to use like so:
I'm envisioning a scala version of this, and perhaps a java8 version (in 2 separate modules, allowing the core API continue to support java6. FYI, there is already a scala module in the 1.x branch. Option 2: Adding a 'verby' module.This would live alongside 'core', etc, and provide an alternate universe of sorts for people who can't stomach the nouniness of the core API. But I'd much prefer the 'compose()' option above. |
anyhow, @ratamacue I guess my answer is that
That work for you? |
FYI, a while back I submitted a refinement of the scala 'compose' idea. This is slated to be released as part of the upcoming 1.x line. |
Instead of extending HTTPObject, I would like to delegate to it. One way to achieve that is to create factory classes that generate HTTPObjects rather than classes that extend HTTPObject.
Instead of:
Something like:
The Method Signature of the HttpObject constructor could take a vararg of handlers (with a check to ensure no duplicate verbs are used) such as
Would anybody on this project object to me adding this interface to HTTPObjects?
The text was updated successfully, but these errors were encountered: