• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

new style/standards document  RSS feed

 
Trailboss
Posts: 22837
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've updated the style sheet. Before I make a link to it, I would appreciate some feedback. Check out www.eporkchop.com/style.html
 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A quick note.
Sun's JAVA code convention wants figure brackets to be put on the same line with the block originator, i.e.
void method() {
// body
}
is preferred over
void method()
{
// body
}
related documents:
http://www.sun.com/workshop/java/wp-coding/
http://java.sun.com/docs/codeconv/html/CodeConventionsTOC.doc.html

------------------
With best of best regards, Pawel S. Veselov ( aka Black Angel )

 
Sheriff
Posts: 440
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I like it. My comments:
I didn't see much on using logic (or I missed it). For example, I think it is always better to use "positive" logic than "negative" logic. i.e.
<pre>
while( number == 0 )
{
do something ;
}
</pre>
Instead of:
<pre>
while( number != 1 )
{
do something ;
}
</pre>
As a newbie, it keeps thing CLEAR as to what is really happening.
Also, I've heard that some people like to put native "private" data types at the end of a class. Reason: someone looking at the code doesn't need to know about it.
Is this correct or (like everything else) personal preferance? I tend to want to know about what I'm looking for right from the top.
Thanks for the insight on some standards, it helps.
Matt
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pawel: This is a big can of worms. I tend to side with Paul, as do most Java and/or C/C++ programmers I happen to know, but I'm always open to reasoned argument. I find the fact that the "{" can't easily be visually matched with the "}" a big hindrance to reading "Sun" style code. Can you give me any actual advantages of this layout over the layout Paul recommends?
Matt: I think this habit is a left-over from some coding suggestions for C++, where the interface for a class is in a "header" file and the implementation is in a different file. In this case, it might make sense for a reader of the header file not to need to know about private members - only a reader of the implementation file would need to know.
In Java, however, there is no such distinction. Any reader or maintainer of a source file needs to see the whole thing, and any style guidelines should suggest a layout which promotes maximum understanding as the file is read through. Personally, I generally prefer to read "bottom-up", so that I am happy with what all the parts do before I consider the whole. For this reason, I tend to prefer the class layout which Paul recommends.
 
paul wheaton
Trailboss
Posts: 22837
Firefox Browser IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Frank. You covered it so well I have nothing to say!
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!