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.
Joined: Oct 06, 2006
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
Joined: Apr 21, 2006
"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)).
Joined: Feb 26, 2006
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
BTW guys i has posted another query regarding Icon Height and the Font Size. Any hints on that one?