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 Code style generall Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Code style generall" Watch "Code style generall" New topic
Author

Code style generall

Gennadi Oreper
Greenhorn

Joined: Mar 09, 2006
Posts: 9
Hello!

Have somebody try to check your code with CheckStyle?

Little questions:
- Is it to pay attention also in e.g. 'choises.txt' that maximum line width is 80?
- If I have any method 'public void doStuff(String value)' checkStyle says, that the parameter should be final declared? Is it needed by String or int?
- at javadoc comments i have a warning: 'line has trailing spaces' (at 2nd line)


What is really important of all it?

Thanks a lot...


_ ____________________ _ <br />SCJP - 1.4<br />SCJD (B&S) - In Progress<br />_ ____________________ _
Brian Kelly
Ranch Hand

Joined: Jan 04, 2007
Posts: 54
1) Why not? I did. Doesn't do any harm.
2) String...I don't really understand. There is no "int" there.
3) No idea...


SCJA, SCJP (1.4), SCJD
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
A tool like CheckStyle offers many different options for style checks. That's because there are amny different opinions about what is good coding style. You can enable and disable each option. If you enabled all options, you would get contradictory error messages. So you can't expect that all the options are really useful. And they certainly aren't all part of Sun's coding standards, which is what you really should be following here.

[Gennadi]: If I have any method 'public void doStuff(String value)' checkStyle says, that the parameter should be final declared? Is it needed by String or int?

Some people (including me) think it's a bad idea to change the value of a parameter within a method. It may confuse newbies who think that this has some effect outside the method (i.e. people who don't understand the difference between pass by value and pass by reference). So some people recommend that method parameters always be declared final. Sun does not however, and for SCJD, I wouldn't do it.

As for the trailing spaces: I don't think it's very important either way. Sun also does not have a recommendation here. However I do think trailing spaces look a little sloppy (for those who use an editor that shows whitespace). And one reason for many coding standard rules is to cut down on the amount of meaningless variation that can appear when studying changes in version control. This is a good example of that.


"I'm not back." - Bill Harding, Twister
Gennadi Oreper
Greenhorn

Joined: Mar 09, 2006
Posts: 9
Hello and thank you!
I have some experience at few big projects, but there is often any own style guides defined...
Now it is interesting and important for me to know, that is relevant for SCJD, and sometimes are any things not allways "unambiguous":-)

Thank's again!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Code style generall