[vtk-developers] style : Holiday greetings and a present of VTK4.0

David Gobbi dgobbi at irus.rri.on.ca
Thu May 24 18:46:27 EDT 2001


On Thu, 24 May 2001, John Biddiscombe wrote:
> At 16:51 22/12/2000, Will Schroeder wrote:
> >Re: [vtk-developers] Holiday greetings and a present of VTK4.0
> >Hi Folks-
>
> One thing that I'd like to see changed is the absolutely rubbish coding
> "style".

Changing the coding style now would be a pain... actually filtering
all the files into a new style wouldn't be too bad, but cvs diffs between
the pre- and post-filtered files would be meaningless.  The VTK code
style isn't the one that I would have chosen, but I don't have any major
gripes with it either.

> I sympathize with the desire to unify coding style, but I have two major
> objections to the current style and one gripe about people in general.
>
> Gripe: Some people out there are clearly using tabs in the editor and they
> are all inconsistent. Every
> if (something)
>    {
>    do something else
>    }
> statement seems to be randomly spread around the screen. How about a ban on
> tab characters or a consistent approach to their use. Use spaces for god's
> sake, they are always the same size.

A good idea, but a little hard to enforce.  I don't mind tabs as long as
they are every 8 chars (which is, as far as I know, the standard).  So
far I've had very little trouble with bad indentation in VTK code, though,
what is your editor's tab stop set to?

> Major objection :
> The use of bracketing like the above wastes space (A new line for every
> bracket). We're all experienced programmers and I for one don't mind minor
> changes in peoples approach to coding, however the one thing that I find
> most useful is a screenful of information.

I agree with you here: I really like the
if (condition) {
  do something;
}
style because it saves space and tightly connects the 'do something' with
the 'condition,' however I don't like
if (condition)
  do something;
because, in C, I like to have all blocks {} delimited.  The trailing '}'
on a line by itself really helps my eyes to break the code into blocks.

I also agree that generally
 - more code per screen is better
but I would also add
 - less code per line is better
and then things balance out nicely.
Blank lines should still be used to separate out
code segments from one another (approx. one blank line per
five code lines seems about right for me).

But I still believe that the VTK code style should be left as is,
I've adapted to it and I don't mind it.

> Major Objection 2:
> Line length. In the days when hairless deviants sat poring over terminals
> connected to a vax mainframe via a PAD line and had green screens with a 40
> character width, it was reasonable to restrict line lengths. But these days
> with super scrolling gui editors and fast searching clickety click mouse
> control, hot keys, bookmarks and all the other modern conveniences, I for
> one do not believe that it's necessary to have 40chars max on a line. If an
> if statement overruns slightly, keep it on one line - AND have the bracket
> there too if you want.

I strongly disagree here.  To much code on one line makes the code much
harder to read.  Lines should be maximum 78 chars, but shorter is even
better.  The thought of using a programming editor with a horizontal
scroll... ugh.  Vertical scroll only for me, please.

> Would I be right in guessing that the current style was chosen to enable
> the dashboard monitoring of defects etc to work rather than a consideration
> of actual coding practices?

I'll have to leave this one for the original developers.

> yours etc etc
> JB
>
> if (StyleChanged) {
>      jumpforjoy(smiling);
> } else {
>      shootme(now(please));
> }
>
> works for me :)

if (EveryonesHappy) {
  hell_must_have_frozen_over();
}
else {
  just_business_as_usual();
}

Ta ta,

 - David





More information about the vtk-developers mailing list