Newsgroupies:
Good guidelines keep source code within a "comfort zone". Programming
languages provide extraordinarily wide design spaces, much wider than
hardware designs enjoy, with many tricks and backdoors that could provide
hours of pleasant diversion writing obfuscated code.
Don't write like that on the job. Always write similar, obvious statements
to do similar, simple things. Engineers learn their working vocabulary from
experience and teammates. A healthy subset of all possible language
constructions keeps everyone sane.
Programming tutorials often contain recommendations like:
* "Make all data private to a class."
* "Program to the interface, not the implementation."
* "No global variables."
* "High level policy should not depend on low level detail."
* "Declare a separate interface for each category of client to a class."
* "No down-casting. Don't use an object's type in a conditional."
* "Don't do too much on one line."
* "Use return to prematurely exit nested loops."
* "Use complete, pronounceable names."
* "Dependencies between modules should not form cycles."
* "Don't allow client objects to tell the difference between servant
objects using the same interface."
* "Don't use anObject.getSomething().getSomethingElse()... too deeply -
tell the target object what your high-level intent is, and let it
pass the message."
* "Different variables holding the same datum should have the same name."
* "Never return null. Never accept null as parameter."
* "In C++, don't abuse #define."
* "Put a class's public things at the top; private things below."
* "Give identifiers the narrowest scope possible."
* Etc...
Such rules are hardly exalted wisdom or exact engineering constraints (and
so is "test-first"). They are easy to remember, and nearly always preserve
code flexibility. All these rules are infinitely debatable. Rules are meant
to be made, followed, and broken.
(Those curious how to follow the rule "never return null" may research a
Refactor called "Introduce NullObject".)
--
Phlip
http://www.greencheese.org/ZeekLand <-- NOT a blog!!!