what to expect while building your first nodejs application

9

Click here to load reader

Upload: ashish-sharma

Post on 02-Jul-2015

136 views

Category:

Engineering


5 download

DESCRIPTION

Here is a small list of things that one who is starting NodeJS based development should expect. Most of these are basically the problems that one might face in course of developing a NodeJS application. Preparing for them in advance by taking specific notice can help in reducing later time wastage on these already identified problems.

TRANSCRIPT

Page 1: What to expect while building your first nodeJS application

Building your first NodeJS

Application

Here is what to expect!

Page 2: What to expect while building your first nodeJS application

NodeJS applications typically

Module ALPHA

A module mashup.

Module BETA

This is a typical NodeJS

application.

Module OMEGA

Page 3: What to expect while building your first nodeJS application

BY what to expect I mean this.

Things to expect to go wrong! Because

good things you would already be expecting .

Page 4: What to expect while building your first nodeJS application

NodeJS Debugging

NodeJS debugging is one of the things that might evoke a WHAAAATTT response in you. It is

quite basic level of debugging in which even the breakpoints need to be added statically to

your code.

A way to circumvent this is to keep methods and modules small and build loosely coupled

modules. If you have been working in a non-functional programming language till now then

you better believe in this advice now or you will feel the pain later.

Page 5: What to expect while building your first nodeJS application

NodeJS Event Loop

From the initial documentation you must have already read about how the NodeJS works

and that it has something called an event loop.

Well the event loop is something like a double edged sword, if you use it correctly it is friend,

otherwise it will cut you.

Page 6: What to expect while building your first nodeJS application

NodeJS Event Loop II

NodeJS makes use of callbacks for I/O operations. Well let me break this news for you, you

should use callbacks even for the CPU intensive operations.

Since the Event Loop runs on single thread, if you go on to do huge amounts of processing in

the event loop then it would slow the whole application down, not just for one request but for

all requests!!!

So this makes it imperative that processing in Event Loop is done just to delegate incoming

requests to call back based asynchronous processing and kept at the bare minimum if you

wish to achieve those juicy throughput numbers in your application.

Page 7: What to expect while building your first nodeJS application

NodeJS Remembering Documentations

You may not find a good IDE for NodeJS just yet. You will have to rely and remember the

documentations a bit more than you did in Java or C++.

But since the included code(dependencies) are all in JavaScript, you can just go ahead

open that dependency file and have your documentation.

Page 8: What to expect while building your first nodeJS application

NodeJS Quickly Crafting Untenable Code

NodeJS, well is a framework that supports JavaScript (a functional programming language)

for its programming. As in other functional programming languages here also you can create

code quickly and that code might become untenable.

Example of such a thing happening are incomprehensible use of function compositions, call

back hell,. Etc.

SO, just stay sharp in keeping your code’s maintainability in check, especially with NodeJS

since the code written here uses starkly different lingo that what you might have written for

browser.

Page 9: What to expect while building your first nodeJS application

Ashish Sharma

Find me at @ashish424242 and @kartaa