|
2. Fundamental Principlesrevised 15 Feb 2001 |
Programming practices don't exist for their own sake -- or at least they shouldn't. This page lists my Koding Kreed.
This is what encapsulation is all about. Be like the civil service in Yes, Prime Minister -- guard information jealously and release it only grudgingly and on a need-to-know basis, but make sure that what you do release can't get you into trouble.
It's better to use somebody else's code than to write my own. The best "somebody else" is the standard C++ library.
A "client" of code is any other piece of code that uses it or depends on it. Since any given piece of code (including a header file) should have more users than implementors, the implementor should expend a little effort to save trouble for the clients.
I will not write C code, compile it with a C++ compiler, and try to pretend that it's C++.
The compiler is very good at checking certain things, like types and
const
-ness (which is part of typing). I will write my
code using safer alternatives whenever possible. I will try to
anticipate run-time problems and capture them in a way that serves the
user best.
Robust code is written to adapt itself readily to unforeseen changes, to let new code be added without having to make major changes in existing code.
It doesn't matter how fast it is if it doesn't do the right thing. (Anyway the compiler can usually do a better job of optimizing than I can.) But I'll follow certain well-known practices that help the compiler optimize.
contact info | site map | |
this page:
http://oakroadsystems.com/codeprac/princ.htm |