The Artima Developer Community
Sponsored Link

Java Buzz Forum
Why you should use coding conventions

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ben Hosking

Posts: 208
Nickname: hoskinator
Registered: Apr, 2006

Ben Hosking is Java Developer with about 5 years experience and interest in OO
Why you should use coding conventions Posted: May 16, 2006 7:25 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Ben Hosking.
Original Post: Why you should use coding conventions
Feed Title: A Funny Java Flavoured Look at the World
Feed URL: http://businesslogs.com/WebLog/RSS.xml
Feed Description: The blog looks at using Java and programming in general as it pops up in life as a Java programmer. It will have links to interesting Java articles and resources. It will also have a lot of SCJP Java 1.5 information and links as I am currently studying
Latest Java Buzz Posts
Latest Java Buzz Posts by Ben Hosking
Latest Posts From A Funny Java Flavoured Look at the World

Advertisement

I have been arguing with my fellow programmer today about coding conventions.  The argument is based around the placing of the curly bracket he likes to do it like this

 

if (boolean statement)

{

    //do something

}

else

{

    //do something else

}

 

and I am now (I had to be made to do it to start with ) do it like this

 

if (boolean statement) {

    //do something

} else {

    //do something else

}

 

 

I think the curly brace argument is one that rages all over the uk, now I used to put the curly braces in the style of the first example because it's easier to see them match up but then our development team call a meeting and we had to choose one way or another but all stick to the same method.  We decided to go with what ever convention Sun recommended in their coding standards document  http://java.sun.com/docs/codeconv/ 

 

The real reason why I am making so much fuss about this is because when ever I have to read his code it looks different than compared to mine and means that the style of the code changes dramatically from class to class.  The reason I want to stick to a coding standard is so all the code looks the same and I can then just worry about what the code is doing rather than where the braces are.  I also thinks it's important to be coding to industry standards because if you change job then it's more than likely the new company will be writing code to the industry coding standards, so you might as well get in the habit now, the longer you leave it the harder it will be to change.  If you really want to stick to the standard I would recommend using checkstyle to help warn/nag you to change the code to fit the standards. 

 

Sun says code conventions are important because

 

 

? 80% of the lifetime cost of a piece of software goes to maintenance.


? Hardly any software is maintained for its whole life by the original author.


? Code conventions improve the readability of the software, allowing engineers to


understand new code more quickly and thoroughly.


? If you ship your source code as a product, you need to make sure it is as well packaged


and clean as any other product you create.


a more important point about all using the same curly bracket convention is that it means when I look at the code I won't have to go through it putting the brackets in the right place, whilst my fellow programmer is putting them all back the other way in an evil catch 22 situation.


 

Read: Why you should use coding conventions

Topic: Think globally, laugh locally Previous Topic   Next Topic Topic: Eclipse3.2RC3

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use