Rest

qznc qznc at web.de
Wed Dec 4 01:09:55 PST 2013


On Sunday, 1 December 2013 at 18:37:25 UTC, guest wrote:
> just wanted to know if something in my code is really bad or 
> could be solved in more elegant way. Basicly things which 
> people with more experience in D see on their first view of my 
> code.

The line splitting in HttpRequest can be simplified with Phobos 
functions. Look into std.array.split.

Not D specific, but you are nesting pretty deeply in my eyes. I 
would for example rewrite the run function:

   foreach(...) {
     if (foo) {
       bla
     }
   }

into

   foreach(...) {
     if (!foo) continue;
     bla
   }

In paramAssignment you could use scope(failure) instead of 
try-catch.

Design-wise your approach cannot be extended with new HTTP 
methods. For example, Subversion uses PROPFIND and REPORT.

You are using classes extensively, but I doubt that OO is the 
best paradigm here. It looks rather functional to me. Each 
request is mapped to a function call. Why grouping this into 
classes?

For my taste there is too much magic (string mixins), but it 
seems necessary for this annotation approach.


More information about the Digitalmars-d-learn mailing list