Home > Uncategorized > Coding Tips

Coding Tips

Conventional code 1:
function isNull( x ) {
if ( x == null ) return true;
return false;
}
Good Style
function isNull ( x ) {
return x==null;
}

Conventional Code 2:

var x ;
if ( cond1 )
x = 10;
else x = 20;

Good style:
var x = 20;
if ( cond1 ) x = 10;
}

Conventional Code 3:
if ( name==”prosunjit” )
print ( “damn programmer!”);
Good Style
if ( “prosunjit” == name )
print (“damn programmer!”);

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: