aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Coding Standard 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 "Coding Standard" Watch "Coding Standard" New topic
Author

Coding Standard

Sam Codean
Ranch Hand

Joined: Feb 26, 2006
Posts: 194
Hi all,
Is there a coding standard limit on the number of lines that should be present in a particular class file?

TIA,
Sameer


-Sam Codean<br />SCJP 1.4 (98%)<br />SCJD 5.0 (87.5%)
Jean S�bastien
Greenhorn

Joined: Oct 06, 2006
Posts: 4
No more than 2000 lines according to

jjguidelines


SCJP 1.4 (95%)<br />SCJD (working on)
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
And according to others there are other limits.
I've seen "standards" stating that any code file longer than 2 printed pages of A4 paper is too long, that's about 120 lines.

The only coding standards you MUST adhere to are the official Sun ones, which don't mention a maximum number of lines (which is a rather silly thing to mention anyway, as one class might be too long at 50 lines, another might need 5000).

Clarity is however often served by keeping things terse, but not so terse it becomes cryptic, and certainly not by keeping things short by sacrificing documentation or resorting to extremely short and cryptic names for methods and variables just to keep the size down.


42
Jean S�bastien
Greenhorn

Joined: Oct 06, 2006
Posts: 4
Actually Sun does mention a maximum number of lines that shouldn't be exceeded which is 2000.

Chapter 3 of the code conventions - File Organization.

Files longer than 2000 lines are cumbersome and should be avoided.


Ofcourse some classes will need more than that. But 2000 lines should be more than enough for the classes created for the SCJD assignments.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
"should be", not "must be"

They strongly advise against it, they don't forbid it.
I've seen that in the past, along with tons of other nonsensical restrictions and requirements.
One company I worked for even had strict requirements for the way comments were constructed, and used an automated checker to make sure everything exactly matched the requirements.
If certain fields didn't exist at specific exact positions in the file (like version number at line 10, column 23 for example) the version control system refused to let you check in the file.
Similarly, they dictated names and how to order them (method names MUST begin with a specific string for example, and MUST be in strict alphabetical order (never mind the logical order of the methods)).
Sam Codean
Ranch Hand

Joined: Feb 26, 2006
Posts: 194
Thanks a Lot folks. Actually i was documenting some stuff and the file became 1000 odd lines so i was wondering. But i think i can generously add comments as long as it does not overwhelm the code itself

Thanks!!

BTW guys i has posted another query regarding Icon Height and the Font Size. Any hints on that one?
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Coding Standard