find-maint: Coding Conventions

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

Menu