File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes What is your style? 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 "What is your style?" Watch "What is your style?" New topic

What is your style?

Ronnie Phelps
Ranch Hand

Joined: Mar 12, 2001
Posts: 329
From what I understand, lines should not exceed 80 and at most 120 characters. I'm not sure of how much emphasis is put on the length of lines when grading the project but I just wanted to get some opinions on how most people would go about shortening a line with more than 120 characters. For example:
<bold>public void updateRecord(long recNo, String[] data, long lockCookie)throws RecordNotFoundException, RecordLockedException;</bold>
would probably be too long for a single line. How would you guys go about shortening this line? All comments are appreciated.
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
I would probably write it like this:

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Franck Rasolo

Joined: May 29, 2001
Posts: 21

IMHO, I would strictly adhere to the conventions defined in the Code Conventions for the Java Programming Language
as well as in the Java Coding Style Guide just to be on the safe side, as the former seem to be missing some.
According to the above, your code should look like this:

Good luck with your assignment!
[ September 15, 2002: Message edited by: Franck Rasolo ]

<i>Franck Rasolo<br />Independent Consultant<br />London, UK</i>
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Ronnie,
I absolutely agree with Franck. I've seen several candidates in recent weeks losing 10 or more points on general considerations. You should follow the link Franck provided or better yet download it and thoroghly read and understand the coding conventions. BTW, according to those conventions, under no circumstances should lines exceed 80 chars. I spent two weeks checking my source code to make sure that I had complied with all the conventions and it paid off with a perfect for general considerations.
Hope this helps,
Michael Morris

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
John Sinues
Ranch Hand

Joined: Feb 21, 2000
Posts: 52
I'm using two products to "validate" my style.
CheckStyle helps Java programmers adhere to a coding standard with the default being Sun's Coding Conventions and Jalopy which is a Java source code beautifier.
One advantage of using these tools is that it provides an automated and consistent coding style throughout your source code.
- John
[ September 16, 2002: Message edited by: John Sinues ]
[ September 16, 2002: Message edited by: John Sinues ]
[ September 16, 2002: Message edited by: John Sinues ]
CyJenny Wong

Joined: May 29, 2002
Posts: 18
how to use Jalopy???
I have downloaded it but I couldn't find the corresponding file for setting the preferences
for the code conventions
Sandra Baker

Joined: Jul 10, 2002
Posts: 26
Hi, but I did not see any requirement stating that we should follow the "java code convention". Also, some codes are really easier to read if leave them to be one line, not wrapping them.
I am extremly frustrated now. I have submitted my assignment, and I keep noticing something I missed...... Is Sun really asking for those patterns, models, and styles in the exam? They are really not in my requirement document.
Too late......
Hope miracle will happen, that's all I can do now.
Wish all of you, who is still in the process, the best luck.
[ September 24, 2002: Message edited by: Sandra Baker ]
I agree. Here's the link:
subject: What is your style?
It's not a secret anymore!