• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Code Conventions

 
David Goate
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Posts: 9795
101
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I too followed strictly Sun's Code Conventions. I also followed strictly the How To Write Doc Comments for the JavaDoc Tool guidelines.
 
David Goate
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 159
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dennis Grimbergen wrote:You won't fail for such minor unimportant things


Agreed.
 
Jayesh A Lalwani
Rancher
Posts: 2756
32
Eclipse IDE Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 159
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 158
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I too followed strictly Sun's Code Conventions.
 
Guillaume Drouet
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic