• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Coding conventions

 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi. I am planning on SCJD, and I am gathering information. My doubt is on code conventions. I am reading Sierra & Bates bonus CD material on SCJD, and one whole chapter is dedicated to coding conventions. For example, they (official Java conventions) that all local variables in a method should be separated with a blank line from the rest of the code. But, I have read on other places that it is good practise to declare variables when they are first used / necessary, which is not neccessarily at the top of the method.
The question is: how strictly should I comply with the standard conventions? I do have quite some Java experience, and my conventions are not always the same as the official ones (but very similar, with a few exceptions), but then again, I don't want to loose point on such a trivial thing. Is it really so important to use the standard conventions?
 
Kevin Florish
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Raf

The SCJD asks you to adhere to the Code Conventions for the Java Programming language.

Code Conventions

If you decide not to follow these conventions you should make that clear in your choices.txt file. People have decided to adopt the standards used
by their IDE but I am uncertain whether they have had marks deducted for this approach.

Cheers Kevin.
 
Raf Szczypiorski
Ranch Hand
Posts: 383
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your reply.
I know the link you sent me to, but I noticed one thing:

The Code Conventions for the Java Programming Language document was revised and updated on April 20, 1999.

Is anyone strictly following these? For example, in the time when 19 inches widescreen displays are pretty common, do developers still limit their code to 80 lines?
 
Kevin Florish
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I went through all my code and restricted each line to 80 chars which makes some lines less readable and isn't what I would do professionally. I
just did this for the SCJD exam.
 
Alex Belisle Turcot
Ranch Hand
Posts: 516
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Raf Szczypiorski wrote:Thank you for your reply.
I know the link you sent me to, but I noticed one thing:

The Code Conventions for the Java Programming Language document was revised and updated on April 20, 1999.

Is anyone strictly following these? For example, in the time when 19 inches widescreen displays are pretty common, do developers still limit their code to 80 lines?


My understanding of this "recommandation" is to make sure it is nicely displayed on any OS with any tools.. By the way, I just edited a java source file in vi on Solaris ten minutes ago... it does happen..

If Java is to be executed anywhere, we should be able to read it everywhere ;) What happens If you print the code ?
Don't get me wrong, I don't personnaly care too much for the 80 characters, I just want to give you some perspective..

Anyway, you should follow it for the SCJD.. And I agree with you, I don't live and die by this rule at work..

Regards,
Alex
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic