Way of the coder

Sat, Dec 16, 2006 2-minute read

No two programmers are created equal, and even though I like to think that I know best, and that the way that I do things are best, I seem to find that in styles of coding people are very different.

I like to create my code so I think its easy to read for others. E.g. whenever I create a method, if statement or other stuff that use curly braces {} I always place them on a seperate line as the only thing on that line. e.g

public bool DoUserExist(string userName)
{
   return false;
}

Other poeple insist on doing:
public bool DoUserExist(string userName){
   return false;
}

I find that annoying, I think the way that I do it makes it easier to see where a statement start and where it ends, when the curly braces are placed on the same like as the statement started, I think they can dissapear from the readers eye.
i.e.
if(true){
   return true;
}else{
   return false:
}

compared to:
if(true)
{
   return true;
}
else
{
   return false;
}

Admittedly the "wrong" coding style makes for more compressed code, but is that good?

Or how about

bool isReady=false;
if(isReady){
   //do the stuff
}

compared to:
bool isReady=false;

if(isReady==true)
{
   //do the stuff
}

i.e. should one write the implicit ==true or ==false in an if statement, I say yes because I think its easier to see what is intended instead of making thinks so compressed.
i.e.

if(!isReady && !canRun)
{
}

compared to:

if(isReady==false && canRun==false)
{
}

 

Just my 0.02$, but its a constant discussion where I'm working, but thats propably the case where ever java/c/c#/javascript programmers meet :p