Finally, although they are not a part of UML, it is appropriate at this point to introduce the role of CRC (class-responsibility-collaboration) cards because they play an important role in validating object-oriented designs. A CRC card is simply a card, such as an index card, on which the description of an object is written. The methodology of CRC cards is for the software designer to produce a card for each object in a proposed system and then to use the cards to represent the objects in a simulation of the system—perhaps on a desktop or via a “theatrical” experiment in which each member of the design team holds a card and plays the role of the object as described by that card. Such simulations (often called structured walkthroughs) have been found useful in identifying flaws in a design prior to the design’s implementation.
Design Patterns
An increasingly powerful tool for software engineers is the growing collection of design patterns. A design pattern is a pre developed model for solving a recurring problem in software design. For example, the Adapter pattern provides a solution to a problem that often occurs when constructing software from prefabricated modules. In particular, a prefabricated module may have the functionality needed to solve the problem at hand but may not have an interface that is compatible with the current application. In such cases the Adapter pattern provides a standard approach to “wrapping” that module inside another module that translates between the original module’s interface and the outside world, thus allowing the original, prefabricated module to be used in the application.
Another well-established design pattern is the Decorator pattern. It provides a means of designing a system that performs different combinations of the same activities depending on the situation at the time. Such systems can lead to an explosion of options that, without careful design, can result in enormously complex software. However, the Decorator pattern provides a standardized way of implementing such systems that leads to a manageable solution.
The identification of recurring problems as well as the creation and cataloging of design patterns for solving them is an ongoing process in software engineering. The goal, however, is not merely to find solutions to design problems but to find high-quality solutions that provide flexibility later in the software life cycle. Thus, 324 Chapter 7 Software Engineering considerations of good design principles such as minimizing coupling and maximizing cohesion play an important role in the development of design patterns.
The results of progress in design pattern development are reflected in the library of tools provided in today’s software development packages such as the Java programming environments provided by Oracle and the .NET Framework provided by Microsoft. Indeed, many of the “templates” found in these “tool kits” are essentially design pattern skeletons that lead to ready-made, high-quality solutions to design problems.
In closing, we should mention that the emergence of design patterns in software engineering is an example of how diverse fields can contribute to each other. The origins of design patterns lie in the research of Christopher Alexander in traditional architecture. His goal was to identify features that contribute to high-quality architectural designs for buildings or building complexes and then to develop design patterns that incorporated those features. Today, many of his ideas have been incorporated into software design and his work continues to be an inspiration for many software engineers.
Questions & Exercises
1. Draw a dataflow diagram representing the flow of data that occurs when a patron checks a book out of a library.
2. Draw a use case diagram of a library records system.
3. Draw a class diagram representing the relationship between travelers and the hotels in which they stay.
4. Draw a class diagram representing the fact that a person is a generalization of an employee. Include some attributes that might belong to each.
5. Convert Figure 7.5 into a complete sequence diagram.
6. What role in the software engineering process do design patterns play?