Should we encourage coding styles in favor of developer's autonomy, or discourage it in favor of consistency?

Posted by Saeed Neamati on Programmers See other posts from Programmers or by Saeed Neamati
Published on 2011-09-13T18:37:40Z Indexed on 2012/03/24 5:38 UTC
Read the original article Hit count: 265

A developer writes if/else blocks with one-line code statements like:

if (condition)
   // Do this one-line code
else
   // Do this one-line code

Another uses curly braces for all of them:

if (condition) 
{
   // Do this one-line code
}
else
{
   // Do this one-line code
}

A developer first instantiates an object, then uses it:

HelperClass helper = new HelperClass();
helper.DoSomething();

Another developer instantiates and uses the object in one line:

new HelperClass().DoSomething();

A developer is more easy with arrays, and for loops:

string[] ordinals = new string[] {'First', 'Second', 'Third'};
for (i = 0; i < ordinals.Length; i++)
{
    // Do something
}

Another writes:

List<string> ordinals = new List<string>() {'First', 'Second', 'Third'};
foreach (string ordinal in ordinals)
{
    // Do something
}

I'm sure that you know what I'm talking about. I call it coding style (cause I don't know what it's called). But whatever we call it, is it good or bad? Does encouraging it have an effect of higher productivity of developers? Should we ask developers to try to write code the way we tell them, so to make the whole system become style-consistent?

© Programmers or respective owner

Related posts about project-management

Related posts about Productivity