This chapter is from the book

This chapter is from the book

1. Concrete Evidence for Reuse

Problem

How can you make sure that in your project building a framework is justified?

Context

You’re working on a project that will see the development of several applications. You have identified some functionality that all applications will probably require. The question of whether it would be useful to have a framework that could provide this functionality arises.

Forces

It is of course tempting to design a framework—the framework could provide a set of common abstractions and could serve as a blueprint for functionality that could then be reused many times. Building a framework can be attractive whenever there is some functionality that several applications will require, though in slightly different ways.

But reuse isn’t the only aspect that lets a framework appear attractive. If you decide to build a framework, many design decisions will be made only once, leading to a consistent architecture across all applications.

Moreover, not all application developers will have to be concerned with all aspects of the software architecture if some of these aspects can be assigned to the framework. In this case, the framework designers can provide an implementation that all applications can inherit. This is particularly useful when it comes to intricate techniques that not all developers have the skill to use.

On the other hand, there is no way to deny that building a framework takes significantly more time than building a normal application. A rough estimate is that developing a framework takes about three times longer than developing an application, though the exact figure depends upon the framework’s size and its degree of abstraction.

In a similar vein, the literature on reuse has a "rule of three," which says that an effort to make software reusable is worth it only when the software is reused at least three times [Jacobsen+1997] [Tracz1995]. A framework needs to be used for three different applications before the break-even point is reached and the investment pays off.

All this suggests that building a framework is justified only if the project can name at least three applications that are going to use it.

A higher number of applications sounds even more promising, but then, there is also a drawback if too many applications are supposed to use the framework: the number of stakeholders can increase to a point where reaching an agreement on the framework’s scope and functionality becomes extremely difficult. The larger the number of potential framework users, the more you need to ensure that using the framework isn’t just an abstract idea, but a concrete possibility.

The dilemma, however, is that you must make the decision for (or against) a framework at the beginning of the project. The application development teams must know as early as possible whether or not there will be a framework they can use. At the beginning of the project, however, the architecture of the individual applications might still be unclear. Perhaps there is even uncertainty about what applications are going to be developed. In other words, you may have to make a decision for or against a framework without knowing much about the applications that might possibly use it.

Solution

Build a framework only if there is concrete evidence that several applications are going to use it.

The emphasis here is on the word concrete. If all you know is that there are several applications that might use the framework, all you can conclude is that framework development might pay off. Or perhaps it won’t.

Therefore, before you decide to build a framework, you must make sure that the preconditions are met:

Three expected uses is a must. If there are four or five applications that you can expect to use the framework, that’s even better, since as a project goes on, things can change, applications may be cancelled, and you may lose a potential user of your framework more quickly than you might think.

Checking for concrete evidence includes seeking an agreement with all stakeholders of the application programs.

The teams who build the applications must make a commitment to using the framework. This is not so much a protection against the not-invented-here syndrome, but a cross-check that using the framework is indeed appropriate. Only the application developers can evaluate how much they could benefit from the framework-to-be.

If you choose to build the framework, calculate about three times the budget you would need to build a single application. If you have concrete evidence for reuse, you can explain why the expected benefits will outweigh the costs.

Examples

The Data Access Layer Framework

At first it looked as if six applications were going to use the database access framework. In the end, one of them didn’t use it for "political" reasons—a consequence of teams from many companies with conflicting goals working on one large project. With five applications remaining (and more expected), building a framework was still justified.

It took the team about 30 person months to complete the database access layer framework. The team estimated that it would have taken about 12 person months to develop a database access layer for one specific application that is equally powerful with respect to business objects and versioning. (However, exact figures would depend on the size of the application’s data model.) Given the fact that building an application using the framework also takes some time, three instances of reuse seemed to be the break-even point in this project.

The Web Portal Framework

When the project started, the decision to build a framework was motivated by the perspective that a number of applications were going to be integrated into the Web portal. After all, the portal was supposed to offer a rich functionality to its users. Work on the framework began quickly, and soon the life insurance system and the customer system were integrated into the portal.

After a while, however, it was recognized that not as many applications were going to be integrated into the portal as had originally been planned, and that for some of these applications a less powerful solution was sufficient. The potential for reuse turned out much smaller than the project had assumed. As of now, the framework has only been used twice, and so far, hasn’t paid off. The budget calculation says the framework might pay off in the future, but only if at least one more application is going to use it which, at this time, is uncertain.

Discussion

In their patterns for evolving frameworks, Don Roberts and Ralph Johnson suggest that Three Examples [Johnson+1998] be developed before building a framework. This recommendation intends to prevent you from not finding the right abstractions or generally heading in the wrong direction with your framework—an easy consequence of a lack of experience.

Yet in many practical scenarios, there are no three examples on which you could possibly rely since the applications will be developed more or less simultaneously to the framework. Is there anything you can do instead to make sure that the framework benefits from experience with application development?

Yes, there is. Because you have concrete evidence for reuse, you must have a good idea of applications that can benefit from the framework, and how. If you choose one or two of those as Pilot Applications (4), you can incorporate feedback from application development into the framework development.

Next, a Skilled Team (3) is certainly helpful. Ideally, team members have developed a framework in such a context before. The more the team members are aware of typical pitfalls in framework development, the better.

Finally, a larger framework will have a higher risk of wrong abstractions and hopes for reuse that won’t materialize. Aim at The Beauty of Simplicity (2).