• Post Reply Bookmark Topic Watch Topic
  • New Topic

Symantecs  RSS feed

 
Charles Hildebrant
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Two days ago I got the book Head on Java which led me to wonder on to the ranch yesterday. I've been programming in C and C++ for some time and I noticed some "old school" symantecs in the book which a haven't seen here yet.

I'm talking about the habit of putting the opening brace on the same line as the opening line of the block. like this:

Instead of:


I'm dyslexic and oh my dog that old style of coding makes it hard to read.

I wonder what the preferred style is here on the ranch.
 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I saw a good write up on indent and brace style on wikipedia here. Myself, I prefer the "Allman" style, probably because I come from a Pascal background.

You can find some javaranch-specific style preference information here. If I'm reading this correctly, it looks as if they prefer the Allman style too.

Good luck!
[ September 29, 2007: Message edited by: pete stein ]
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Charles Hildebrant:
...I wonder what the preferred style is here on the ranch.

Welcome to JavaRanch!

I think you will find that this is entirely a matter of individual preference -- and people tend to be very set in these preferences.

For what it's worth, Sun's Code Conventions for the Java Programming Language places the opening brace at the end of the line. This is also the style used in the Java Language Specification, as well as popular Java textbooks, such as Head First Java, Thinking in Java, and The Java Tutorial.

Keep in mind that whatever style you choose to use yourself, it's inevitable that you will see other styles used (including formatting that looks entirely random).
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[pete stein]: You can find some javaranch-specific style preference information here. If I'm reading this correctly, it looks as if they prefer the Allman style too.

That's the official position of ranch management. Not necessarily the preference of all individuals involved. (Which is probably true of most style guides anywhere.)
[ September 29, 2007: Message edited by: Jim Yingst ]
 
Charles Hildebrant
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fascinating...

Those styles are named. Without knowing the name I've had a preference for the Allman style and I'm well pleased to see that is preferred here as well.

Thanks for the welcome Marc. I enjoy ranches and especially saloons.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!