Putting cyrus-future code in CVS. Also, code style
Patrick Goetz
pgoetz at mail.utexas.edu
Tue Jun 29 13:22:42 EDT 2010
Bron Gondwana wrote:
> Also, a question about coding style. Is it codified somewhere?
> There are a few different styles throughout the code, but there
> seems to be a fairly consistent style in most of the code.
>
Having spent many hours recently looking over Cyrus C/perl code (and not
having had to spend much time looking at other people's code in the
preceding 5-10 years), I will happily volunteer my opinion that in
practice, and for future maintenance purposes, the K&R style:
while (x == y) {
something();
somethingelse();
if (some_error) {
do_correct();
do_something_else;
}
else
continue_as_usual();
}
sucks and is hard to read, while the GNU style
while (x == y)
{
something ();
somethingelse ();
}
is just kind of silly. Most readable is the Allman style:
while (x == y)
{
something();
somethingelse();
}
That little bit of added white space really makes a difference when the
eye is skimming down the page. Since I always use the Allman style and
am usually only debugging my own code, I didn't really appreciate the
difference until looking at Cyrus code. Indentation doesn't matter so
much to me for readability, but I diverge from the norm by preferring a
2-space indentation to keep nested blocks from drifting too far off to
the right which also creates more work for the eye when re-reading code,
not to mention line wrap. Mostly I don't think about this much, as vi
does all the indentation for me as I edit.
More information about the Cyrus-devel
mailing list