From: Martin D. <mar...@te...> - 2003-09-03 08:34:30
|
Hello all There is some precision about my complain in the last IRC about jaloppy not being "intelligent" enough. It is a nice attempt, but it always applies Sun convention (or any other se of convention) blindly. In a real code, I believe that we are always facing compromise at some point. Example: Methods arguments: I tend to group together related arguments, e.g.: void doSomeStuff(double x1, double y1, double z1, double x2, double y2, double z2); Jaloppy break this tabular formatting. A human know that (x1,y1,z1) and (x2,y2,z2) form groups; it is more difficult for a program to see that. Braces after 'if' statement: We should uses { ... } most of the time, but there is exception. Example: if (x < xmin) xmin = x; if (x > xmax) xmax = x; if (y < ymin) ymin = y; if (y > ymax) ymax = y; Jaloppy add braces and put the assignement on the next line, which break the tabular format and make the code more difficult to read. Spaces around operators: we should put spaces around some +, -, * or / operations, but we don't have to put spaces always (authors of the book "Numerical Recipes in C++" do not put spaces at all!) Again, sometime I do not put spaces when I want to logically group some variables. For example I wrote: dx*dx + dy*dy + dz*dz Which, in my opinion, is easier to read than: dx * dx + dy * dy + dz * dz Adding parenthesis everywhere doesn't help; it put yet more symbols. Line length: some time I do some compromise in order to fit in the 100 character limits. Jaloppy don't. For example I wrote: someVeryLongStuff[i+1]; Jaloppy reformat as: someVeryLongStuff[i + 1]; Which is worst in my opinion! There is full of details like that. My opinion is: we should use jaloppy in order to clean a code in bad shape, then lets the human formating untouch (providing it is done right after jaloppy cleaning, otherwise we can run jaloppy one more time). Programming is doing compromise. An automatic tools is not close to understand all the compromise one can found in a code formatting, as the idea behind the organisation of elements in tabular format, or the use of spaces for grouping some elements together in an expression, etc. Martin. |