Tibor's Musings

Programming for Reusability: Cheap or Expensive?

When programming, one can write off a task quickly, or one can make components modular and reusable for the future. The latter obviously takes more time. But how much? And when it is worth the effort?

Mythical Man-Month

Fred Brooks in MMM summarises that reuse is a nice theory, but hard practice. The price to pay for "writing for reusability" is about threefold:

"Parna writes: "Reuse is something that is far easier to say than to do. Doing it requires both good design and very good documentation. Even when we see good design, which is still infrequently, we won't see the components reused without good documentation". Ken Brooks comments on the difficulty of anticipating _which_ generalization will prove necessary: "I keep having to bend things even on the fifth use of my own personal user-interface library." [...] DeMarco says: "I am being very discouraged about the whole reuse phenomenon. There is almost a total absence of an existence theorem for reuse. Time has confirmed that there is a big expense in making things reusable." Yourdon estimates the big expense: "A good rule of thumb is that such reusable components will take twice the effort of a 'one-shot' component." I see that expense as exactly the effort of productizing the component, discussed in Chapter 1. So my estimate of the effort ratio would be threefold." (MMM, p.224)