Skarmander said:
Roberto Waltman wrote:
Code carefully and beautifully formatted in somebody's
Carefully, beautifully and (as I infer) *manually* formatting code is a
tremendous waste of time, and as you've discovered, it's not a stable process.
If you use tabs, use them for logical indentation, not to produce a
particular amount of whitespace, and your formatting problems vanish into
thin air. For all the rest there's pretty printers, or, in these modern
times, IDEs with autoformatting.
I typed that "keyboard in cheek." Of course I use "tabs" for logical
indentation, (as in, press the tab key at the beginning of that line,
indent that line; select a group of lines or a C block, press tab,
indent the whole block; press shift-tab or whatever, un-indent the
whole block etc.) But after configuring my editor, I trust it to never
insert an actual tab character in the file. Otherwise the formatting
problems do not "vanish into thin air", because the presence of tabs
is what created them in the first place. (And yes, I use programs as
astyle and indent, or whatever the IDE du jour will provide)
This is more on topic in this newsgroup than others, as C programmers have a
long and venerable tradition of formatting code in a myriad different ways,
each superior to the others. One shudders to think at the amount of
productive coding time that must have been wasted by people laying out their
source code to look good on their monitors, only to be tempted to do it all
over again when they change tab sizes, monitors, or personal predilections.
I agree. I am fighting this at work now. In one of the projects I am
working now, I adopted the style of one of my colleagues to make sure
she will not waste time reformatting my code to her liking when she
has to use it.
Hm. If this sounds like a flame to you, please ignore it. Formatting issues
rarely spawn productive discussions, but I had to get it out of my system.
Nope. I strongly believe that adherence to coding standards (covering
much more than indentation style) does indeed help to produce better
quality software. For any project involving more than one programmer,
it makes much easier to understand, integrate, reuse, test, etc. each
others code.
Tell it to one of my colleagues, that likes to declare macros that
expand to function declarators + the initial brace of a function body.
[ /* this is a complete function */ MACRO statement; statement; ... }
] This makes the code more difficult to read in addition to breaking
the functionality of pretty-printers and editors that allow you to
jump to the beginning of a block, or function, etc.
Or to another, that always puts a return statement at the end of void
functions, and adds this line to the end of every file:
/**************** end of file *********************/
(I guess I should be grateful, that stops me from going on editing
vacuum...)
Or to another, that the only comments that he ever uses are like this:
/* these lines changed by ???? */
/* end of changed lines */
Information I can easily get from CVS, and totally useless to
understand the reasons for the code changes.
I guess I had to get this out of my system too ...