Forums Register Login

Java Style

+Pie Number of slices to send: Send
I have thought for a long while whether the question i m about to ask is worth asking or is it not. But my curiosity floods all my senses for me to ask you this: I read in a book a couple of days ago that the java convention for compounds statements is to put the opening brace directly after the, for example method declaration:
public void whyThisStyle(){
//code
}
I m used to putting both braces in a line such as:
public void whyThisStyle()
{
}
I deem it (personal taste surely)to be more readable, and however, it appears that the convention dictates suc ha personal (and trivial in a way) topic. Why is that?
+Pie Number of slices to send: Send
it appears that the convention dictates suc ha personal (and trivial in a way) topic. Why is that?
Basically because if they don't, many developers will spend too much time arguing about their favorite style with the other developers. If code is written by one person and then edited by someone else with a different style, it becomes harder to read; better to have everyone on a team using the same style, regardless of what that style is.
That's true for any large project under some sort of central control, anyway. There really is no single style that everyone who programs Java follows. Sun has their own style which is used by many other companies as well, but this is not absolute. No matter what your preference, it's entirely possible you'll find yourself working with a team of people who requires you to do it differently. A good programmer should be able to adjust their style easily to meet their local community standards.
As far as which style is really better, and why - this question will never really be resolved. You can find a good recent discussion here.
+Pie Number of slices to send: Send
 

Originally posted by Jim Yingst:
As far as which style is really better, and why - this question will never really be resolved. You can find a good recent discussion here.


It's been resolved a long time ago, the K&R adherents just haven't caught on yet
+Pie Number of slices to send: Send
A pox on thee, unbeliever!
+Pie Number of slices to send: Send
I think the reason a lot of programmers use the endOfLine block opening brace is that you gain a few lines. This may be contentious, but I believe any method larger that one page becomes harder to validate visually and this layout allows a few more lines of programming per page. Of course, indenting, meaningfull names and vertical spacing is vital to ease the understanding of a method.
This parrot is no more. It has ceased to be. Now it's a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 709 times.
Similar Threads
IBM jCert Exams Info
Coding convention for annotation
JavaBean name convention
Exception doesn't tell me where it occurs
inner class question
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 11:07:07.