Node.js Development: Frequent Errors Made by Node.Js Developers - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
leenajose
V2EX    Node.js

Node.js Development: Frequent Errors Made by Node.Js Developers

  •  
  •   leenajose 2015-08-17 15:44:23 +08:00 3340 次点击
    这是一个创建于 3717 天前的主题,其中的信息可能已经有所发展或是发生改变。
    Programmers prefer a framework to develop an application or website for several reasons such as simplicity of usage, demands of the task assigned, and reliability. Node.js falls in the list of such frameworks which a developer chooses to build complex applications. It is a programme widely accepted by multi-national business giants to run their web applications. Node.js, being an extensively used platform has received many favorable as well as unfavorable remarks. Most of the times, developers who switched to Node.js, having elemental knowledge in similar programs, stumble upon several errors. Article refers certain errors a novice Node.js developers commits.

    Event loop blocking

    Since Node.js program is made to support complex applications, event loop happens to be a most important function. Any function written to the code which blocks the event loop will bring a wait signal to all the customers, or clients connected to the server. The program works on single thread; hence a Node.js developer should defer loops that hinder the event loop to an independent worker or queue. The problem occurs with cases such as when a developer parses functions having heavy payload with JSON. parse (), syntax highlighting done to the backend files using highlight.js, and the one-time parsing of massive files. All these are common errors in coding that lead to the blocking of an event loop. A developer can identify the error in coding which hinders the smooth working of an event loop by tracking the time delay. ‘ Blocked ’ is a proprietary open source module used to detect time delay between the functions called inside a loop. Delay occurs in the event loop should be correctly identified to spot anomalies in coding.


    Triggering a call back () many times

    Developers often execute a call back function twice on the process of running an application. They ignore to return a function after the instant execution. Many events in an application are triggered by passing functions as references. These references act as call backs. Call back is the only way in Node.js to make the asynchronous elements work properly. A function, in Node.js coding is added as a last argument while executing asynchronous tasks. Hence, executing a callback () many times without returning the values of first called function completely will result in a crash while dealing with Node.js . A temporary option to avoid this error is the inclusion of a return keyword ahead of executing callback functions.


    Callback Hell

    Call back Hell is a problem not solely associated to Node.js. It is one of the common issues which all complex frameworks have to deal with. According to the complex nature of applications, developers add nested callbacks leading to a scenario which makes things difficult to read. Maintaining of codes will be hard at this time. One of the finest options to solve this is the writing of simple functions and a proper linking of them all. To a large extent, a Node.js developer can depend on packages like Async.js, Promises, and Generators to lessen errors occur with Callback hell. Following of these modules will help programmers a lot in maintaining the codes neat and tidy.


    Unawareness of development tools

    Any modifications done to the source code of Node.js should be followed by a restart. Together with it, developers have a tendency to refresh the browser while static codes change leading to a slowdown in the performance of applications. There are certain modules like nodemon and forever that will help the developers to restart the server with the change of files, automatically. Similar to nodemon, livereload is another tool which aids you to refresh the browser timely after the change in static codes.

    Visit source Link: http://agriyaservices.blogspot.in/2015/08/nodejs-development-frequent-errors-made.html
    jiangzhuo
        1
    jiangzhuo  
       2015-08-17 18:50:34 +08:00
    不错的文章,头像是楼主本人。
    good blog , Avartar is author herself 。。。。
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     6093 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 28ms UTC 02:05 PVG 10:05 LAX 19:05 JFK 22:05
    Do have faith in what you're doing.
    ubao msn snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86