• Post Reply Bookmark Topic Watch Topic
  • New Topic

Formatting Question  RSS feed

 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • 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
  • 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: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!