Contemporary object-oriented programming languages employ the class as the unit of reuse. At the same time, the class is also the unit of design. This implies that to reuse a class, the design of the class must fit the design in which it will be reused. While this serves planned reuse, it hampers unplanned reuse. Obviously, unplanned reuse is much more important if widespread reuse is desired.

What is the difference between both of them?


Despite the fact the original cite is ~15 years old, I doubt classes have ever been "the primary units of reuse" outside of some academic books and schools. The object-oriented black-box unit of reuse of today is typically a component - which means a self-contained library with a contract, an interface with a clear syntactical and semantical description, and machine readable meta information which allows some kind of introspection. Some of the available component technologies of today allow programming language independendent reuse.

A typical component consists of one or more classes (and can at least theoretically be implemented without any classes at all), but "the class" is typically just a "unit of design" (a tool to give your code more structure), not a "unit of reuse". For some components, one class may be enough, but that is more an exception than the regular case.

Furthermore, other, older forms of creating reusable units like building libraries or modules are still popular, but those do not even need the notion of object-orientation or classes. When you look today at the big collections of reusable software available at the web, the "reusable units" which are single classes are only a small percentage, compared to the total number of reusable components, libraries or modules. That should make the difference very clear.

  • I wanted to understand the difference - did not mean to say that it is contemporary. the text was to provide some context on what I was having in my mind when asking the question. But thanks. This clears the air. – vanangamudi Jun 2 '15 at 10:00

The unit of design means when you sit down to design a new program, you are basically deciding on a set of classes you will include.

The unit of reuse means if you want to reuse functionality someone else has written, the smallest unit you can pull into your new program without making a new copy of the code is an entire class. As Doc Brown pointed out, often because of coupling that unit is even larger. You can't reuse just one method, or just the data structure without any methods, as is common in functional and procedural paradigms.

Most OO programmers don't realize how big of a problem this actually causes for reuse. Generally, classes must be carefully designed with reusability in mind, and mainly only library designers go to the trouble.

The smaller the unit of reuse, the smaller the probability that the unit is specific to a single application. That's why the most successful reused code uses very small, widely-accepted, general-purpose interfaces. For example, a simple compare interface on a type allows that type to be reused in a wide range of existing code, from sorting algorithms to data structures like binary search trees. Note, however, that the reused code must have been initially designed in order to take advantage of that interface.


If the class is the unit of design, it mes that you design your code one class at a time. You should be able to old pretty much the entire purpose and implementation of the class in hour head at one time, you would commit its code to the project all at once, or within a short time, etc.

If a class is the unit of reuse, it just means that when someone wants to reuse your code, he's supposed to take the entire class and do something with it, e.g. call its methods or maybe inherit from it - not to copy one of its method and make modifications. "Class as the unit of reuse" is a popular notion because it means you could distribute your class in a compiled form and have it reused without exposing the source code (this is less convincing now than it used to be, because so many practitioners have embraced the idea of open-source software, but you'd be surprised how many decision-makers are ridiculously behind the times).

Obviously, these two ideas don't have to be true at the same time. You could design an entire module at a time and still want to reuse only a little code snippet from one corner. Therefore it's a good idea to have a clear conception of what a class is and how it should be used by authors, co-developers and application programmers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.