DESIGN PATTERNS :-
•
The best designers in any field have an mysterious ability to see
patterns that characterize a problem and corresponding patterns that can be
combined to create a solution.
•
These patterns solve specific design problems and make
object-oriented design more flexible, well-designed, and ultimately reusable.
They help designers reuse successful designs by basing new designs on earlier
experience.
•
A designer who is familiar with such patterns
can apply them immediately to design problems without having to remember them.
•
Throughout the OOD process, a software engineer should look for
every opportunity to reuse existing design patterns (when they meet the needs
of the design) rather than creating new ones.
a) Describing a Design Pattern :-
•
older engineering disciplines make use of thousands of design
patterns. For example, a mechanical engineer uses a two-step, keyed
shaft(arrow) as a design pattern. Inherent in the pattern are attributes (the
diameter(distance) of the shaft, the dimensions(scope) of the keyway, etc.) and
operations (e.g., shaft rotation, shaft connection). An electrical engineer
uses an integrated circuit (an extremely complex design pattern) to solve a
specific element of a new problem.
•
All design patterns can be
described by specifying the following information.
1) the name of the pattern
2) the intent(objective) of the pattern
3) the “design forces” that motivate the
pattern
• Design forces describe the data,
functional, or behavioral requirements associated with part of the software for
which the pattern is to be applied. In addition forces define the constraints
that may restrict the manner in which the design is to be derived.
4) the solution that mitigates(reduce)
these forces
• In real meaning, design forces describe
the environment and conditions that
must exist to make the design pattern applicable.
5) the classes that are required to
implement the solution
6) the responsibilities and
collaboration among solution classes
• The pattern characteristics (classes,
responsibilities, and collaborations) indicate the attributes of the design
that may be adjusted to enable the pattern to accommodate a variety of
problems.
• These attributes represent characteristics
of the design that can be searched (e.g., via a database) so that an
appropriate pattern can be found.
• 7) guidance
that leads to effective implementation
• 8) example
source code or source code templates
• 9)
cross-references to related design patterns
b) Using Patterns in Design :-
•
In an object-oriented system, design patterns can be used by
applying two different mechanisms: inheritance and composition.
•
Using inheritance, an existing design pattern becomes a template for a new
subclass. The attributes and operations that exist in the pattern become part
of the subclass.
•
Composition is a concept that leads to aggregate objects. That is, a problem
may require objects that have complex functionality (in the extreme, a
subsystem accomplishes this).
•
The complex object can be assembled by selecting a set of design
patterns and composing the appropriate object (or subsystem). Each design
pattern is treated as a black box, and communication among the patterns occurs
only via welldefined interfaces.
•
object composition should be favored over inheritance when both
options exist.
•
Rather than creating large and sometimes unmanageable class
hierarchies (the consequence of the overuse of inheritance),composition favors
small class hierarchies and objects that remain focused on one objective.
Composition uses existing design patterns (reusable components)in an unaltered
form.
No comments:
Post a Comment