• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Code style generall

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...
 
Wanderer
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Gennadi Oreper
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
    Bookmark Topic Watch Topic
  • New Topic