Unit_1_SADP
Unit_1_SADP
Design Pattern
Introduction
• Patterns help you build on the collective experience of skilled
software engineers.
• They capture existing, well-proven experience in software
development and help to promote good design practise.
• Every pattern deals with a specific, recurring problem in the design or
implementation of a software system.
Contents
• What is a pattern?
• What types of pattern are there?
• Why do we use patterns in software architecture?
• What does a pattern look like?
• How can we use patterns in our work?
What is a pattern?
Definition:
A particular recurring design problem that arises in specific design
contexts, and presents a well-proven generic scheme for its solution.
The solution scheme is specified by describing its constituent
components, their responsibilities and relationships, and the ways in
which they collaborate.
Definition in English…
• A re-usable solution to a recurring problem
• Tried and tested
• Consider the solution to be a template
• It can be adapted and personalized for the problem domain
The separation of the model from the view and controller components allows multiple
views of the same model.
Model-View-Controller
Model-View-Controller
Change a subsystem of the application without causing major effects to
other subsystems.
For example, you can change from a non-graphical to a graphical user
interface without modifying the model subsystem.
Model-View-Controller
We can derive several properties of patterns for software architecture
Model-View-Controller and the associated pattern has been to the Smalltalk community
since the early '80s, and is used by many software engineers
Model-View-Controller
Patterns are a means of documenting software architectures
can describe the vision you have in mind when designing a software system
helps others to avoid violating this vision when extending and modifying the original
architecture
extend a new function: keep core functionality separate from user input and
information display
Context :
Describing situations in which the problem occurs
Specifying the correct context for a pattern is difficult
A more pragmatic approach is to list all known situations where a problem that is
addressed by a particular pattern can occur
What Makes a Pattern?
Problem:
Description schema describes the problem that arises repeatedly in the given
context
Requirements the solution must fulfil-for example, that peer-to- peer inter-process
communication must be efficient.
Constraints you must consider-for example, that inter-process communication must
follow a particular protocol.
Desirable properties the solution should have-for changing software should be easy.
The Model-View-Controller pattern from the previous section specifies two forces:
1. It should be easy to modify the user interface,
2. But the functional core of the software should not be affected by its modification.
What Makes a Pattern?
Solution :
Shows how to solve the recurring problem, or better, how to balance the forces
associated with it
Every pattern specifies a certain structure, a spatial configuration of elements
Pattern Categories
Patterns into three categories:
1. Architectural patterns
2. Design patterns
3. Idioms
Architectural Patterns
An architectural pattern expresses a fundamental structural organization schema
for software systems.
It provides a set of predefined subsystems, specifies their responsibilities, and
includes rules and guidelines for organizing the relationships between them
Solution:
A reference count is added to the body class to facilitate memory management.
It is the responsibility of any operation that modifies the state of the body to break the
sharing of the body by making its own copy, decrementing the reference count of the
original body
Integration with Software Development
Architectural patterns can be used at the beginning of coarse-grained design, design
patterns during the whole design phase, and idioms during the implementation phase
Relationships between Patterns
A pattern solves a particular problem, but its application may raise new problems
Single components or relationships inside a particular pattern may therefore be
described by smaller patterns, all of them integrated by the larger pattern in which they
are contained
Relationships between Patterns
Example Refinement of the Model-View-Controller pattern
The Model-View-Controller pattern separates core functionality from human-computer
interaction to provide adaptable user interfaces applying this pattern introduces a
new problem
Views, and sometimes even controllers, depend on the state of the model
The consistency between them must be maintained
we must not lose the ability to change the user interface
Each pattern depends on the smaller patterns it contains and on the larger
patterns in which it is contained
At the design level, most patterns only require certain abstraction facilities of a
programming language, such as modules or data abstraction.
You can therefore implement patterns with almost any programming paradigm and in
almost any programming language