File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes about { } notation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "about { } notation" Watch "about { } notation" New topic
Author

about { } notation

Andrea Gazzarini
Ranch Hand

Joined: Sep 09, 2002
Posts: 125
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


Regards,<br />Andrea<br /> <br /><a href="http://www.linkedin.com/in/andreagazzarini" target="_blank" rel="nofollow">Andrea Gazzarini</a><br />Skype ID : gazzax72<br />Google Talk ID : a.gazzarini@gmail.com<br /><a href="http://www.andreagazzarini.blogspot.com" target="_blank" rel="nofollow">My Blog</a>
parthiban subramaniam
Ranch Hand

Joined: May 15, 2002
Posts: 116
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 ]

Even crazy and silly looking problems are sometimes real.
Andrea Gazzarini
Ranch Hand

Joined: Sep 09, 2002
Posts: 125
Sorry,the original message was something like
public class A
{
// public void method()
///{
///}
}
instead of
public class A {
// public void method(){
///}
}
Juan Katabasis
Ranch Hand

Joined: Jun 20, 2001
Posts: 46
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 ]

Regards<br />J.
Kathy Sierra
Cowgirl and Author
Ranch Hand

Joined: Oct 10, 2002
Posts: 1572
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.


Co-Author of <a href="http://www.amazon.com/exec/obidos/ASIN/0596007124/ref=jranch-20" target="_blank" rel="nofollow">"Head First Design Patterns"</a><br /> <br />Just a Jini girl living in a J2EE world.
Andrea Gazzarini
Ranch Hand

Joined: Sep 09, 2002
Posts: 125
Thanks to everyone..!!
Ashik Uzzaman
Ranch Hand

Joined: Jul 05, 2001
Posts: 2370

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.


Ashik Uzzaman
Senior Member of Technical Staff, Salesforce.com, San Francisco, CA, USA.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Feb 26, 2001
Posts: 5287
    
  10

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.


Junilu - [How to Ask Questions] [How to Answer Questions]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about { } notation