Do we have to have the coding standards discussion again? OK then.

Folks get attached to their coding styles, I know I do, it sounds like Leon (another Aussie blogger) is attached to hungarian notation. Coding styles are closely related to coding standards (its when someone tries to push their coding style onto others).

Coding standards is one subject that gets raised alot by our clients. Once upon a time I would have dug out mountains of coding standards documents that I have fallen victim to in years past, but these days I like to point them to this piece by Chris Sells. I must be a real hippy because I’m not even that fussed about number one. The simplicity is beautiful I think.

Having said that I do generally try to stick to the “external” naming conventions recommended for the platform I am using. This means taking the time to read the platform documentation. Even if they don’t have specific guidance the actual class libraries that ship out of the box usually provide enough of a hint.

At the moment, when creating the source file, the only wart I use is a ‘m_’ in front of private fields (protected and public fields to be named according to platform guidance). But I was contemplating changing that in the next few days, just to see how it goes. I think doing things like using methods as comments has a greater impact on readability and mantainability anyway.

When did you last change your coding style?

4 thoughts on “Do we have to have the coding standards discussion again? OK then.

  1. Alex Hoffman

    I too used to be a religious hungarian notation coder, but have changed my coding style to the “standard” for .NET code other than some stuff in managed C++. I use a _ in front of private fields.

    What most irks me is when I see .NET code in what I gather is ASP script notation – apparently a lower case “o” in front of a variable used to be the rage.

  2. Mitch Denny

    Yep, I used to do that (the “o” wart). I moved on from that when I figured it didn’t seem to add that much value. In fact the “m_/_” wart is really there because of VB.NET (the IDE doesn’t differentiate on case so it “corrects” you typos for you), even though I do most of my coding in C#.

  3. secretGeek

    there’s nothing like a standards war to inject a little team-a-cide.

    personally I’ve dropped use of underscores as prefixes for private members, because the .Net IDE’s section separators cover up the underscores, so if you’ve written:

    Dim _Salesman as Dickhead

    , it looks like you’ve written:

    Dim Salesman as Dickhead

    C# coders can do this:

    Dim slave as Slave

    Which is the ms recommended style, even though it doesn’t work for second class VB.net citizens!

    we can often avoid the issue by choosing a better name:

    Dim Worker as Slave

    or:

    Dim WorkerSlave as Slave

    but if the instance really has to be called “slave” then the only appropriate option I can find is:

    Dim oSlave as Slave

    hence, the “o” wart may live on, in place of the “_” wart….

    here endeth the rant

    cheers

    lb

    (sorry for the lateness of the comment, I’ve been off line all week)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s