File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

about { } notation

 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can I use the
public class A
{
public void method()
{
...
}
}
instead of
public class A {
public void method() {
...
}
}
braces coding convention???
I've read the sun coding conventions but nothing is written about it.
Thanks
 
parthiban subramaniam
Ranch Hand
Posts: 116
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
to me this looks better ..
class Example{
// void method(){
// }
}
ignore the //
what do you say ?
cheers,
parthi
[ October 17, 2002: Message edited by: parthiban subramaniam ]
[ October 17, 2002: Message edited by: parthiban subramaniam ]
 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry,the original message was something like
public class A
{
// public void method()
///{
///}
}
instead of
public class A {
// public void method(){
///}
}
 
Juan Ec
Ranch Hand
Posts: 46
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if it compiles i don't see why you can't use it, but it's not on the way of the Code Conventions for the JavaTM Programming Language, just take a look at the example file

[ October 17, 2002: Message edited by: Jaun Katabasis ]
 
Kathy Sierra
Cowgirl and Author
Rancher
Posts: 1589
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can answer this one with certainty, because this was just confirmed: you MUST follow the official Java Coding Conventions. You will have points deducted if you don't, no matter how consistent you are. There has been confusion about this, because the exam instructions often just said, "coding standards" without specifying WHICH standards, so now it's been finalized.
And unfortunately, that means...
public void go() {

}
cheers,
Kathy
p.s. the good news is, you may spend the rest of your life and never have to adhere to that particular style guide, but for the exam, you can assume that Sun is your client, and they require you to use their conventions.
 
Andrea Gazzarini
Ranch Hand
Posts: 125
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks to everyone..!!
 
Ashik Uzzaman
Ranch Hand
Posts: 2373
Eclipse IDE Firefox Browser Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I always liked the
while(true){
... if(i>=0){
....i+=10;
..}
}
like things due to a touch of elegance. And now I am confirmed it's official also.
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
So the difference between a Java developer and a Java programmer could be that you have the opening bracket on the same line as the method name and the if stmt and so forth. Fantastic !
/T
 
Junilu Lacar
Bartender
Pie
Posts: 6529
21
Java Linux Mac Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Torgny Wikstr´┐Żm:
So the difference between a Java developer and a Java programmer could be that you have the opening bracket on the same line as the method name and the if stmt and so forth. Fantastic !
/T

Sarcasm doesn't do you any good. We all probably, at some point in time, have rolled our eyes at such seemingly trivial things like this but that's the world we have to live in. It's been said that what differentiates a professional is his/her ability to do the job well even if he/she doesn't like it. As Kathy said previously, you should think of Sun as your client for this project. As the client, Sun has the right to demand things such as adherence to a coding convention and the developer should be obliged to stick to it. If you don't like it, you can either suck it up and comply anyway or be bull-headed and ignore it. If you choose the latter, then, as in real life, you should be prepared to take the consequences.
 
Anonymous
Ranch Hand
Posts: 18944
  • 0
  • send pies
  • Quote
  • Report post to moderator
Since there are beautifiers to get, and run, it's no big deal. But, deducting points if the bracket is on the "wrong" line is. The compiler doesn't care. If you get pointe of for some strange design that's understandable or if your code looks like a complete mess.
/T
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic