The content in this article is a mix of original material and material adapted from Visual Basic 6: Error Coding and Layering (Prentice Hall, 2000, ISBN 0-13-017227-8) and the upcoming book Planning Smarter: Creating Blueprint-Quality Software Specifications (Prentice Hall, 2001).

From the author of

From the author of

To reuse code effectively, you have to write code that's worthy of reuse. "Reuse-quality"
code must be flexible enough to accommodate the widest range of needs. It must
be robust enough that the user doesn't have to risk his or her project on unreliable
code. It must be standardized enough that the user can immediately understand
what to expect from the code, how it works, and how to maintain it. Finally,
it must be written efficiently enough to be cost-effective. If any of these
requirements are not met, users will find it easier and faster to reinvent the
wheel.

So how do you create reuse-quality code and still stay under budget?

Step 1: Eliminate All Assumptions

Assumptions are the root of most coding problems, including a lack of reusability.
One such assumption is "No one will ever need this again." If you
start with that assumption, you'll never build reuse-quality code.

Every routine should be written as if it will be reused—even if it won't.
Failure to do so undermines the level of consistency and standardization in
the code, reducing quality and maintainability.

Eliminate other assumptions about how and when the code will be used. Develop
each routine as a completely generic function.