cbuschka / beanshell2

Automatically exported from code.google.com/p/beanshell2
0 stars 0 forks source link

Establish coding conventions / consistent source formatting #26

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
I suggest adopting some (written) coding conventions to keep the source
easier to read, and to avoid some common pitfalls that occur when the
compiler is the only syntax verification step.

Sun has published a set of guidelines that look fairly reasonable, and
should be easy to configure an IDE to help enforce:

http://java.sun.com/docs/codeconv/

(My biggest complaint with these standards is the liberal use of /* */
comments, instead of // comments, and that there is no distinction in
variable naming for instance variables, but I think this is good enough.)

They can also be partially enforced with indent(1) although I have no
experience with that tool myself.

If there are no objections, or other suggested guides to consider, then
I'll start working on this in a day or two, and try to work through the
codebase gradually as I learn the structure of the code myself.

Original issue reported on code.google.com by cresw...@gmail.com on 15 Feb 2009 at 9:11

GoogleCodeExporter commented 9 years ago
Sun's coding standard is outdated for indentation. They have the 'four spaces 
for first indent, but tab to capture two indents' silliness arrived at through 
emacs defaults. Please consider something -- anything -- more sensible. I've 
seen both the following alternatives, and they are all superior to Sun's 
standard:
  1. always tabs, a tab per indent level
  2. never tabs only spaces, each indent level is 2/3/4 spaces

Original comment by dilum.ra...@gmail.com on 27 Sep 2010 at 3:30

GoogleCodeExporter commented 9 years ago
Also, 80 characters as max width is also outdated. Pretty much all screens can 
fit more, and most printers can print more. But this is not nearly as painful 
as the indenting standard.

Original comment by dilum.ra...@gmail.com on 27 Sep 2010 at 3:32

GoogleCodeExporter commented 9 years ago
The 80-character thing is not a factor of screen/printing width, but 
readability.

re: tabs/spacing and indents -- I'm in the "never use tabs" camp.

Anyhow, I've pretty much moved away from Java for the foreseeable future, so my 
preferences shouldn't be weighed heavily, if at all ;)

Original comment by cresw...@gmail.com on 27 Sep 2010 at 4:31