find-maint: Coding Conventions

 
 4 Coding Conventions
 ********************
 
 Coding style documents which set out to establish a uniform look and
 feel to source code have worthy goals, for example greater ease of
 maintenance and readability.  However, I do not believe that in general
 coding style guide authors can envisage every situation, and it is
 always possible that it might on occasion be necessary to break the
 letter of the style guide in order to honour its spirit, or to better
 achieve the style guide's goals.
 
    I've certainly seen many style guides outside the free software world
 which make bald statements such as "functions shall have exactly one
 return statement".  The desire to ensure consistency and obviousness of
 control flow is laudable, but it is all too common for such bald
 requirements to be followed unthinkingly.  Certainly I've seen such
 coding standards result in unmaintainable code with terrible
 infelicities such as functions containing 'if' statements nested nine
 levels deep.  I suppose such coding standards don't survive in free
 software projects because they tend to drive away potential contributors
 or tend to generate heated discussions on mailing lists.  Equally, a
 nine-level-deep function in a free software program would quickly get
 refactored, assuming it is obvious what the function is supposed to
 do...
 
    Be that as it may, the approach I will take for this document is to
 explain some idioms and practices in use in the findutils source code,
 and leave it up to the reader's engineering judgement to decide which
 considerations apply to the code they are working on, and whether or not
 there is sufficient reason to ignore the guidance in current
 circumstances.
 

Menu