• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What is your style?

 
Ranch Hand
Posts: 329
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would probably write it like this:
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ronnie,

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 ]
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how to use Jalopy???
I have downloaded it but I couldn't find the corresponding file for setting the preferences
for the code conventions
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic