Adept Software Development

Adept: (A)pplication (D)evelopment (E)nterprise to (P)ersonal (T)ransition. It is a system I am developing to leverage Enterprise developer skills to produce stand-alone software for other market segments. This is a general software development blog discussing issues about project, architecture, design and development. The emphasis will be in Java, but many of the issues will be more general. Almost all will be technical.

http://marringtons.com

Friday, July 22, 2005

Coding Standards and Breaking the Rules - Part 1, Layout

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.

0 Comments:

Post a Comment

<< Home