Code style generall

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)

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

posted Feb 14, 2007 22:52:00

0

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":-)