Archive

Posts Tagged ‘programming’

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!”);