Is the original poster's code really made up of little pieces each of
which someone would be excited to have as a reusable module? Is dicing
it up into more files really going to help? I don't think so in this
case. It's very task-specific.

Which is why, right on the callbackhell.com website, the author
advocates using the async module for complex cases. (:

On Tue, Sep 16, 2014 at 6:16 AM, Floby <[email protected]> wrote:
> Hello.
>
> This is a problem newcomers face so often that there is a website for it
> http://callbackhell.com/
>
> This website show that "callback hell" is really just about how you
> structure your code.
> Any construction that increase your cyclomatic complexity is bad (callbacks,
> promises, generators and whatnot included).
>
> The most effective method I found for handling this is reading
> callbackhell.com and Clean Code [1]
>
> [1]
> http://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882
>
> On Monday, 15 September 2014 18:28:28 UTC+2, Ingwie Phoenix wrote:
>>
>> Hai, everyone.
>>
>> So I just figured out that Connect’s static file servers dont work well
>> with symlinks…so I had tow rite myself a little workaround, a fallback
>> router, per-se. But whilst I did so, I had a nice meeting with the callback
>> hell. Here’s my code:
>>
>>             CDN.use(config.CDN.baseUrl, function(req, res, next){
>>                 if(err) { next(); throw err; }
>>                 fs.lstat(config.base+"/cdn"+req.url, function(err,stats){
>>                     if(stats.isSymbolicLink()) {
>>                         fs.readlink(config.base+"/cdn"+req.url,
>> function(err, linkstr){
>>                             if(err) throw err;
>>                             log.info("Redirecting request \""+req.url+"\"
>> to \""+linkstr);
>>                             fs.readFile(linkstr, function(err, data){
>>                                 if(err) throw err;
>>
>> res.writeHead(200,{"Content-type":"text/html"});
>>                                 res.end(data);
>>                             });
>>                         });
>>                     }
>>                 });
>>             });
>>         });
>>
>> Okay…thats lots. And how does one get around this and into a bit of nicer
>> code? It almost looks like a little pyramid there…
>>
>> Kind regards, Ingwie.
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to a topic in the
> Google Groups "nodejs" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/nodejs/wBAJhYOzjqQ/unsubscribe.
> To unsubscribe from this group and all its topics, send an email to
> [email protected].
> To post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/6af70f61-43a5-4bb7-8f77-f0c163f48dcf%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 


THOMAS BOUTELL, DEV & OPS
P'UNK AVENUE | (215) 755-1330  |  punkave.com

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAORXhGKLwCBWW_wvzL50D-zA_q0PXFFdbyCaeAbxiSYAF6fg2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to