Have you changed your coding style recently? It wasn't hard wasn't it?

Posted by Ernelli on Programmers See other posts from Programmers or by Ernelli
Published on 2011-02-12T13:14:58Z Indexed on 2011/02/12 15:32 UTC
Read the original article Hit count: 483

Filed under:
|
|

I've used to write code in C-like languages using the Allman style, regarding the position of braces.

void foo(int bar)
{
  if(bar)
  {
     //...
  }
  else
    return;
  //...
}

Now the last two years I have been working mostly in JavaScript and when we adopted jslint as part of our QA process, I had to adopt to the Crockford way of doing things. So I had to change the coding style into:

function foo(bar) {
  if (bar) {
     //...
  } else { 
    return;
  }
  //...
}

Now apart from comparing a C/C++ example with JavaScript, I must say that my JavaScript-Crockford-coding style now has spread into my C/C++/Java coding when I revise old projects and work on code in those languages that for example has no problem with single line statements or ambiguous newline insertion.

I used to consider the later format very awkward, I have never had any problems with adapting my coding style to the one chosen by my predecessors, except for when I was a Junior developer mostly being the solve developer on legacy projects and the first thing I did was to change the indenting style.

But now after a couple of months I consider the Allman style a little bit too spacious and feel more comfortable with the K&R-like style.

Have you changed your coding style during your career?

© Programmers or respective owner

Related posts about coding-style

Related posts about habits