Recent Posts

Archives

Topics


« | Main | »

Standards – Introduction

By sparky | September 12, 2008

From time to time, standards are created; They’re not a bad thing ultimately – except when you have certain groups or individuals that try to push – and force – them onto people to follow.
One popular one that has been discussed / debated is the ‘web standards’; but that isn’t the point of todays post.

Rather, coding standards.
These are important to ensure others can come along, be able to read and interpret your code, and make changes / modifications – as needed.

I’m no pro. In fact, I’m still very early in my tertiary education – however already I encounted a bit of a ‘dilemma’ in coding standards.

Comments – always needed. Really. Although tedious, when someone comes along debugging, they can see what each part of the code does – assuming it isn’t clear from just reading the code itself.

When I first started coding Java (first few weeks), eclipse – my choice of editors – had a tendency of putting the opening brace { under the ‘head’ of the statement, with the closing brace } in line with the statement:

if (x == 9)
{

}

Then I recieved a ‘standards’ document, which told me I had to place the opening brace at the end of the statement, same line, and then the closing brace in line with the head of the statment:

if (x == 9) {

}

When I first read this, I felt that there must be something wrong. I was partially influenced by my tutorial teach who was saying he preferred the former method.
But then, after discussion with the two other contributors to this site, and my programming lab instructor, I changed my mind, realising that the later is in fact the better way; especially when looking at hundreds of lines of code. Makes it neater, and eliminated unnecessary line spacing – which is used to just have one brace on it.

The moral of the story: Standards are a good idea, and I encourage all to try find some that are used in the industry, or area, that you work. It’ll make a lot of people happy :)

Topics: Principles, Programming | 1 Comment »

One Response to “Standards – Introduction”

  1. Long Says:
    September 13th, 2008 at 8:53 pm

    I do that with CSS. It looks prettier that way.

Comments