How To Apply Design Patterns when Designing Software
Once you have identified a design pattern that helps solve your problem, this Slideshow illustrates the steps to take to use the pattern effectively: The following series of images explore how to use a pattern.
The first thing you should do is study the pattern so that you are sure you understand it
Map the generic pattern into your specific problem
Adopting a pattern often requires you to add, remove and reorganize the classes and objects in your system
You will need to implement the pattern in code. This is often the easiest part of programming with patterns.
Describing Design Patterns
What constitutes an effective articulation of design patterns? It is clear that reliance on graphical representations alone is inadequate. Such diagrams merely delineate the final form of the design as a network of relationships among classes and objects. For the design to be truly reusable, it is imperative to document the rationale, the various alternatives considered, and the compromises that shaped the final design. Additionally, the utilization of tangible examples is crucial; they illuminate the application of the design, bringing it to life. We articulate design patterns through a standardized approach, systematically organizing each pattern into segments based on a predetermined framework. This uniformity in structure enhances the digestibility, comparison, and practical application of design patterns.
Pattern Name and Classification
The pattern's name conveys the essence of the pattern in a nutshell. A good name is vital, because it will become part of your design vocabulary.
A short statement that answers the following questions:
What does the design pattern do?
What is its rationale and intent?
What particular design issue or problem does it address?
A scenario that illustrates a design problem and how the class and object
structures in the pattern solve the problem. The scenario will help you understand the more abstract description of the pattern that follows.
What are the situations in which the design pattern can be applied?
What are examples of poor designs that the pattern can address?
How can you recognize these situations?
Participants: The classes and/or objects participating in the design pattern and their responsibilities.
Collaborations: How the participants collaborate to carry out their responsibilities.
Consequences: How does the pattern support its objectives?
What are the trade-offs and results of using the pattern? What aspect of system structure does it let you vary independently?
What pitfalls, hints, or techniques should you be aware of when implementing the pattern? Are there language-specific issues?
Code fragments that illustrate how you might implement the pattern in C++ or Java.
Examples of the pattern found in real systems. We include at least two examples from different domains.
In the analysis phase, a partial understanding of the problem is transformed into a precise description of the tasks that the software system needs to execute. The result of the analysis phase is a detailed textual description, commonly called a functional specification, that has the following characteristics:
It completely defines the tasks to be performed.
It is free from internal contradictions.
It is readable both by experts in the problem domain and by software developers.
It is reviewable by diverse interested parties.
It can be tested against reality.
Consider the task of writing a word-processing program. The analysis phase must define terms, such as fonts, footnotes, multiple columns, and document sections, and the interaction of those features, such as how footnotes in multiple-column text should look on the screen and the printed page. The user interface must be documented, explaining, for example, how the user is to enter and move a footnote or specify the font for footnote numbers. One possible format for an analysis document is a user manual, very precisely worded to remove as much ambiguity as possible.
Another common format for describing the behavior of a system is a set of use cases.
A use case is a description of a sequence of actions that yields a benefit for a user of a system. At least in principle, it should be possible to list all benefits that a system can communicate to its users and supply use cases that show how they can be obtained.
The analysis phase concerns itself with the description of what needs to be done, not how it should be done. The selection of specific algorithms, such as those that insert page breaks or sort the index, will be handled in the implementation phase. It is possible to use object-oriented techniques in the 1) analysis phase as well as 2)the design phase. An advantage of that approach is that the object model of the analysis phase can be carried forward to the design phase. A potential pitfall is that customers of a software product are generally not familiar with the terminology of object orientation. Clients may not find it easy to tell whether the analysis will lead to a product that satisfies their needs.
CRC cards: (Class, Responsibilities, Collaborators) are an activity bridging the worlds of role-playing games and object-oriented design.
functional specification: A functional specification (FS) in software development is a document that describes the features and functionality of a software product. It is a key component of the software development process, and it is used to communicate the requirements of the product to the developers.