29 August 2009

Scott Meyers: Good Library Design

Some principles that make for better libraries:
  • Make classes and functions easy to use correctly, hard to use incorrectly.
  • Obey the principle of least astonishment.
  • Avoid gratuitous incompatibilities with the built-in types.
  • Use const whenever possible
  • Avoid duplicating code.
Scott commented that the first principle listed is a "Hallmark of a professionally designed library."

And the for the third principle listed, "When in doubt, do as the ints do."


This is from material and notes taken at the 2002 C++ Seminar in Boston during the session about Library Design and the C++ Standard Library by Scott Meyers.

These still seem like sensible principles to keep in mind as one develops code.

No comments: