C Language

Discipline Has Its Rewards

Discipline also is the key to achieving gains in productivity and quality from code reuse - the major motivation behind the creation of C++. No matter how powerful C++ facilities are for object-oriented programming, a slapdash approach to creating classes won't result in substantial code reuse. Because it's too expensive and risky to reuse poorly organized, poorly documented, or unreliable classes, programmers using C++ will continue to write mostly from scratch, unless a class library makes their jobs easier, rather than harder.

By now it may sound like the only way to work with C or C++ is to keep a cane switch handy to whip programmers into submission. That's not the case. The "discipline" I'm speaking of is more akin to the discipline good athletes demonstrate in the preparation and execution of their sport. Like successful athletes, top-flight programmers, project leaders, and managers have learned that although discipline takes effort, it brings satisfaction as well. Discipline can free developers from the crush of problems caused by little, unavoidable mistakes and can make possible the use of more powerful software development techniques.

In programming, discipline applies to creating and following programming standards and a well-defined development process. Many standards and process steps should be formal, written ones, but a programmer also must be disciplined enough to follow unwritten principles of good programming practice. For example, no simple written standard can say, for all circumstances, when to reuse an existing class and when to create a new one. In the absence of any written standard, an undisciplined programmer might choose whichever is easiest at the moment; a disciplined programmer will examine the alternatives and carefully consider the balance between short- and long-term costs and benefits. In general, discipline involves thinking about more than just a single program, and thinking beyond just today's problems.

by BrainBellupdated
Advertisement: