[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Debian coding style?



> 15. Duplicate blocks of code should be avoided. If the same code is needed
> in more than one location, place it in a separate function and call it from
> where ever it's needed.

Oh, forgot to mention in the last email: it's sometimes wasteful of
resources or just really inconvenient to do this if this repeated
block of code relies on lots of locally scoped variables.  With
literate programming, you can include the same block of code in
multiple locations without defining a function.  Go look!

> 16. Goto statements should not be used.
> 
> 17. Return: functions and methods should be structured to have a single
> return.

Old debate.  See for example, for the opposing view, D.E. Knuth,
"Structured programming with goto statements", Computing Surveys 6
(December 1974), pp 261--301.  Reprinted in D.E. Knuth, Literate
Programming, CSLI Lecture Notes.  I guess similar arguments would
apply to returns as well.  Of course, if you document what you are
doing very well, and use these constructs with care, then it doesn't
necessarily matter.

   Julian

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

  Julian Gilbey, Dept of Maths, QMW, Univ. of London. J.D.Gilbey@qmw.ac.uk
             Debian GNU/Linux Developer.  jdg@debian.org
       -*- Finger jdg@master.debian.org for my PGP public key. -*-


Reply to: