• 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

Formatting Question

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Between


and


which one is it that we are to use? Javaranch says the former, many examples from Sun show the latter
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Arthur,

There's no one correct way. For your own you should choose one of them, and use that in all your code. When you work for a company they usually have their coding standards so in that case use that of course. I personally prefer the second one.
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And I prefer the first one. Like Miklos said, the right version to use depends on the environment; if it's your own code simply choose one (1! 1! ) and stick to that.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I prefer the second one, but that might just be because I learned CSS conventions in the same format.

Compilers of course doesn't recognize the line break there, so you could choose either one (as the guys above stated), and as you said, Sun shows the latter and JavaRanch shows the former. Both are probably the most widely accepted conventions for formatting, but I happen to see the second much more frequently (which means nothing about how you should write).


The other issue I have is whether or not to add a space after something like:


or



And also for arrays:


or



Head First Java has both at different times, and I'm not sure what the proper thing to do is. I tend to simply put the () or [] right next to the word it applies to, similar to how one would do with a method or when using an array reference, but I see it written in so many different fashions that it often makes me wonder what the more acceptable way is to do it, so I certainly understand your train of thought.


Take a look at this: http://www.javaranch.com/styleLong.jsp#format
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic