[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Coding Style
From: |
John W. Eaton |
Subject: |
Coding Style |
Date: |
Tue, 21 Feb 2006 00:18:22 -0500 |
On 20-Feb-2006, Bill Denney wrote:
| So, I generally don't code things the same way that is generally used in
| the internals of Octave. One thing I was just looking at was the current
| plotting routines (with gnuplot), and I noticed that some parts
| (specifically in bar.m) had
|
| if (something)
| ...
| else
| error (message)
| endif
|
| My general preference is to have code indented less, and I think that
| less indentation generally makes code more readable. I would code it as
|
| if (~ something)
| error (message)
| endif
| ...
|
| So I have two questions: is there a document that describes current
| coding preferences in octave? Is the previous coding method preferred for
| some reason or was it just how the code came out?
I prefer to avoid negation of conditions where possible. Also, the
if (things_are_ok)
do_the_intended_stuff ();
else
error ("some message");
endif
style follows the convention used in much of the C++ code in Octave,
where I generally try to have only one return statement in a
function.
jwe
- Coding Style, Bill Denney, 2006/02/20
- Coding Style,
John W. Eaton <=