Concept

Software Reuse

Definition

Software reuse is the practice of building new systems out of existing, proven parts — components, libraries, frameworks, and design templates — instead of writing every piece from scratch. The reused unit can be code, but it can equally be a design: a tested arrangement of responsibilities that you instantiate again in a new context.

Reuse is as much an economic argument as a technical one. A component that has already been written, debugged, and run in production carries reliability that brand-new code cannot match, and it amortizes the original development cost across every system that adopts it. The design challenge is to make parts reusable without making them so general that they become hard to understand or to wire together.

Why it matters

How it works

Mechanisms of reuse

Reuse happens at several scales. Libraries package callable routines you invoke. Frameworks invert that relationship — the framework calls your code at defined extension points, reusing an entire control structure. Design patterns reuse a proven arrangement of collaborating classes without reusing any specific code. Each mechanism trades a different balance of convenience against flexibility.

Inheritance versus composition for reuse

Two object-oriented mechanisms enable reuse, and they differ sharply. White-box reuse through class inheritance is reuse by extending an existing class; it is straightforward but exposes the subclass to the parent's internals, creating tight coupling. Black-box reuse through object composition assembles behavior from objects accessed only through their interfaces; nothing internal is exposed, so the parts stay independent and reconfigurable at run time. Favoring composition keeps reused parts loosely coupled, which is what lets a system keep absorbing new requirements.

Where it goes next

Continue exploring

Tags