[Adept Software Development] Coding Standards and Breaking the Rules - Part 1, Layout

1 view
Skip to first unread message

Paul Marrington

unread,
Jul 22, 2005, 6:43:14 AM7/22/05
to adeptr...@googlegroups.com

Coding Standards and Breaking the Rules - Part 1, Layout

Code Layout

I have always been a bit of a heretic when it comes to coding standards. I like, for example, to have the braces on their own lines with a double-index before and after.
    if (instanceData == null)
      {
        instanceData = new InstanceData();
    /* more code goes here */
      }

    /* Code outside the if */

 

I have never had any trouble reading code using differed layout styles - except in that some styles are intrinsicly a little harder to scan.
    if (instanceData == null) {
        instanceData = new InstanceData();
    /* more code goes here */
    }

    /* Code outside the if */

 

I do concede, however, that a single style should be used in a file or at least method body. Otherwise it can be very confusing.

Having said that, I recognise that many people are militant about enforcing layout styles, and it is really not so important to me that I will make an issue for them.

Of course if you want a particular style, all the IDEs will reformat a file to your specifications. Don't do it to others. Many people get annoyed when their file is changed. More importantly, don't do it during the release phase of an iteration. Tracking changes is much harder when the whole file has changed.

--
Posted by Paul Marrington to Adept Software Development at 7/22/2005 08:37:00 PM

Reply all
Reply to author
Forward
0 new messages