On Thu, 10 Oct 2013 12:34:54 GMT, Dejan Lekic wrote:
Is it me, or get() is a really confusing method. We do not get anything, instead we set with it...
I'd say it's just as confusing as put()
, post()
and all the others. However, it's very convenient in such a place where usually many calls are made in sequence. I'm usually not a fan of abbreviations of this or other kinds, but here I think it's OK because it is very commonly used and very easy to remember - but maybe that's tainted by the fact that I know it from other frameworks. At least nobody has complained about this before (but of course that is not a valid argument, just an indication that the situation may not be that bad).
The good news is that it's planned to add UDA support to URLRouter
, so that the code would look similar to this:
@method(HTTPMethod.GET) @path("/")
void showHomepage(HTTPServerRequest req, HTTPServerResponse)
{
// ...
}
void main()
{
// ...
router.addRoute!showHomepage();
}
More to type and higher cognitive load (IMO), but better encapsulation and unified handling between URLRouter
, registerRestInterface
or registerFormInterface
.
But apart from that I'm struggling with finding a better naming scheme:
matchGetRequest()
: descriptive but far too much to typematchGet()
: still confusing (maybe not as much), but also longer to typeGET()
: arguable less confusing and still concise, but completely goes against the code conventionsmatchGET()
: not confusing, more to type - probably the best candidate, but it also adds a lot of redundant text for a sequence of many routes