Share via


Coding conventions

<rant>

Most of the coding convention I've seen being used by SW houses seems to promote wastage of lines. I suspect that since in many cases code size is measured in LOC it actually helps quoting a larger number. E.g. I start getting a tad irritated when I have to write code as follows

 // Why do I have to put in the enclosing curly braces :(
if(flag)
{
   Func();
}
 // Can't I just use get { return foo; } and set {foo = value; }
public CFoo Foo
{
    get
    {
        return foo;
    }

    set
    {
        foo = value;
    }
}

</rant>

Comments

  • Anonymous
    September 10, 2007
    The comment has been removed

  • Anonymous
    September 10, 2007
    The comment has been removed

  • Anonymous
    September 10, 2007
    I prefer the style you refer to as a waste of lines. And I am not measured by LOC. What I don't like is your CFoo (waste of letters?).

  • Anonymous
    September 10, 2007
    It's all about what works for you, but to me the MOST important thing when writing code is to adopt a coding standard that promotes easy reading. if (1==) {   some condition; } if (2==2) {   some other condition; } is easier to read (for me) than if (1==1)  some condition; if (2==2)  some other condition; The number of lines doesn't matter to the compiler...

  • Anonymous
    September 11, 2007
    The comment has been removed

  • Anonymous
    September 11, 2007
    This should really be a matter for the display from an IDE.  It's more personal taste and preference then "Coding Standard"  If the IDE just displayed code blocks in a user defined manner, almost every one would be happy.

  • Anonymous
    September 11, 2007
    I agree with the other commenters.  "Waste of lines", when I bought my computer I opted for the unlimited # of lines...

  • Anonymous
    September 11, 2007
    For me it's not "waste of lines", it's readability. But in contrast, what do you think about writing space after "if", "for" statements. What about casting? To space or not to space? :)

  • Anonymous
    September 12, 2007
    The comment has been removed

  • Anonymous
    September 13, 2007
    The comment has been removed

  • Anonymous
    September 17, 2007
    I doubt there will ever be consensus here. Opinions will always vary on the subject. My own I personal preference is what you call "wasted space". It's not becuase I'm judged by LOC or anything like that, but because I believe the "wasted space" makes for a more readable and maintainable document.

  • Anonymous
    September 20, 2007
    The comment has been removed

  • Anonymous
    November 15, 2007
    For maintenance sake, make it easy on the poor guy who will need to read and update the code.  Can anyone imagine if the code follows no convention, looking like K & K, ATT C, C++, Java, C#, and others all in one?