aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Code Conventions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Code Conventions" Watch "Code Conventions" New topic
Author

Code Conventions

David Goate
Greenhorn

Joined: Jan 08, 2013
Posts: 7
Hi everyone,

I have a question about code conventions for the certification.

I am using Maven for my build process and I am using tools such as checkstyle and PMD. I don't recall seeing a concrete requirement to abide by the standard Java code conventions so I am unsure as to whether candidates would lose marks if they don't strictly conform. I understand that if I'm not consistent in my formatting across the entire source base then it would make the code harder to read and the marker may have a negative view on this. Also in terms of maintainability it would be better to be as consistent as possible.

However, there are a couple of aspects of the standard conventions I would prefer to change, for example, the 80 character line width restriction I would like to increase to between 120-140. Also, due to the environment in which I currently work I am used to putting brackets and so on on new lines and find this more natural e.g.



instead of



That said, I would hate to drop marks just for some personal preferences so if necessary I will stick to conventions.

Is there anyone who has not followed strict conventions and scored full marks?
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5539
    
  13

I scored full marks (in 2009), but followed the sun coding conventions, even the 80 characters per line one. In my current development I think that's one of the few which is updated to more present standards.

But I guess the most important thing (like you already indicated) is being consistent through your complete project (use a formatter in your IDE). I think that's more important than just following oracle/sun's coding conventions (but it's not a guarantee).


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

I too followed strictly Sun's Code Conventions. I also followed strictly the How To Write Doc Comments for the JavaDoc Tool guidelines.


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
David Goate
Greenhorn

Joined: Jan 08, 2013
Posts: 7
Thanks for that. I think for the sake of being safe I will stick to the conventions as much as possible.

I am using eclipse Indigo as my IDE and I was using the Java Conventions formatter and a couple of save actions, but I am finding that it is not correctly removing trailing white-space from JavaDoc comments (actually it even inserts them when there aren't any), which is causing checkstyle to fail. Also it is not correctly wrapping lines even though the line width is set to 80, there are various lines that are 85, perhaps even 95 lines long...

I think I'll need to spend some time checking all of the Eclipse settings and try reformatting the code...
Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 143

I completely ignored the 80 character line width restriction. I noted in my choices.txt that 80 characters makes code less readable. Nowadays it's easy to put 160 chars on a line.
You won't fail for such minor unimportant things


SCJP, SCWCD, SCJD
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2267
    
    3

Dennis Grimbergen wrote:You won't fail for such minor unimportant things


Agreed.
Jayesh A Lalwani
Bartender

Joined: Jan 17, 2008
Posts: 2433
    
  28

It's been a while since I have taken the certification exam, so take this post with a huge grain of salt.

As a person whose job is to do code reviews, small deviations from the standard might be minor inconveniences, but you put many of them together and they become a huge problem. It's like getting stabbed with a plastic fork. One stab, you can ignore; ten stabs, annoying; 100 stabs, stop it!!!; 1000 stabs, kill me please. If you are deviating from a well established standard, don't deviate too much
Dennis Grimbergen
Ranch Hand

Joined: Nov 04, 2009
Posts: 143

Jayesh A Lalwani wrote:If you are deviating from a well established standard, don't deviate too much

Maybe this established standard needs an upgrade...
James X Peterson
Whizlabs Java Support
Ranch Hand

Joined: Feb 26, 2013
Posts: 158
I too followed strictly Sun's Code Conventions.
Guillaume Drouet
Ranch Hand

Joined: Apr 16, 2012
Posts: 36
Me too (including 80 characters per line). However, you can choose any conventions since you justify it in your choices and you striclty follow them everywhere in your code !
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Code Conventions