Do One Thing And One Thing Only

Proposal: A SoftwareComponent must perform only one task. This makes the component reusable because its functionality can be used by any application.


example

For example, a gasoline engine is relatively the same in an SUV, sedan, and a motorcycle. If the engine somehow "knew" it was inside a Toyota Camry, other engines would have to be built specifically for other types of cars. [Note: this example is somewhat skewed; engines for trucks, cars, and motorcycles are 'radically different from each other. Even between different types of trucks or cars or motorcycles the engine tuning is vastly different. So, yes -- other engines do need to be built for other types of cars.]

In general, yes, car engines are bigger and tuned differently than motorcycle engines. However, I've heard that the Geo Metro and Trabant (Trabi) automobiles use the same engine as some motorcycles. If that engine refused to operate unless it was inside the motorcycle it was designed for, then...

Perhaps a better example would be a specific size of nut and matching bolt. The functionality it provides can be used several times in a single car, and also used in totally different contexts such as a backyard deck.


Lasers for dentistry need to be aware they are burning flesh and would thus stop when getting too deep or encountering something they shouldn't be touching.

The whole point of building software is to make things smart, to make them capable.

A reusable laser component has an interface which allows the intensity to be specified. Certainly other components may use it and add their own BusinessRules. Note that I said SoftwareComponent and not software in general.


For anal retention purposed this page/principal should be called DoExactlyOneThing. See OnceAndOnlyOnce for this discussion.

CategoryComponents


EditText of this page (last edited January 3, 2004) or FindPage with title or text search