Download as ppt, pdf, or txt
Download as ppt, pdf, or txt
You are on page 1of 17

Design

Design Patterns
Patterns
CE00362-3
CT070-3-3

Design Patterns – An Introduction


Introduction & Overview

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 1 (of 18)


Learning Outcomes

At the end of this session, you should be


able to;

• Describe why patterns are required


• Impetus behind the use of patterns
• Describe what is a design pattern
• Relate origins of software patterns
• Relate design patterns essentials
• Relate patterns in software development
lifecycle

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 2 (of 18)


Impetus behind the use of patterns

• designing reusable software is hard


• novices are overwhelmed
• experts draw from experience
• some design solutions reoccur
• understanding reoccurring solutions is
beneficial in several ways

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 3 (of 18)


Why Patterns?

“Wisdom is often ascribed to those


who can tell just the right story
at the right moment and who often
have a large number of stories to tell.”

Robert C. Shank

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 4 (of 18)


What is a Pattern?

“Each pattern describes a problem which occurs


over and over again in our environment,
and then describes the core of the solution
to that problem, in such a way that you can use this
solution a million times over,
without ever doing it the same way twice.”

Alexander et al.

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 5 (of 18)


What is a Pattern?

Patterns are proven solutions

“Once is an event, twice is an incident,


thrice it's a pattern.”
Jerry Weinberg

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 6 (of 18)


The Origins of Design Patterns

• They originate from the work of Christopher


Alexander, a building architect in the 1970’s.
• Alexander’s idea was to improve the quality of
the buildings of the time by utilising proven
‘patterns’ of good architectural design.
• ‘Each pattern describes a problem which occurs
over and over again in our environment, and
then describes the core of the solution to that
problem.’

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 7 (of 18)


From Buildings to Software

• Alexander’s work ‘discovered’ by Kent Beck


and friends in the 1980’s.
• They applied Alexander’s ideas about
constructing buildings to the building of
software.
• Patterns are found in all areas of computing,
from user interface design, the writing of
device drivers to the use of databases.

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 8 (of 18)


What is a Design Pattern?

• A design pattern is defined as ‘a description of


communicating objects and classes that are
customised to solve a general design problem in
a particular context’.
• Patterns capture good design principles and
communicate them to others.
• Design patterns represent the first legitimate
attempt at design reusability.

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 9 (of 18)


What is a Design Pattern?

“A methodology tells you how to write down the


decisions you have made.
A pattern tells you which decisions to make,
when and how to make them,
and why they are the right”

Beck & Johnson

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 10 (of 18)


Design Patterns: Essentials

• Patterns are found through trial and error and by


observation.
• In general a design pattern has four essential
elements:
– The pattern name
– The problem the pattern is used to solve
– The solution or template for implementing the
pattern
– The consequences or results of applying the
pattern.

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 11 (of 18)


Patterns in the S/W Development
Lifecycle

• Design patterns are considered complementary to


existing object-oriented methodologies.
• Success in using design patterns largely depends in
the correct selection of the appropriate pattern.
• Knowledge and understanding of the use of existing
documented patterns is all important.
• Therefore the way patterns are catalogued must be
unambiguous and complete.

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 12 (of 18)


The ‘Gang of Four’

• The most widely known work on design patterns is that


of ‘Gamma, Helm, Johnson and Vlissides‘. The ‘gang of
four’ as they are commonly referred to.
• Their book ‘Design Patterns: Elements of Reusable
Object-Oriented Software’ was published in 1994.
• It contains a description of the concepts of patterns, plus
a catalog of 23 design patterns with their full
documentation.

Selective GOF patterns will be covered


in depth in subsequent lectures
CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 13 (of 18)
The ‘Gang of Four’

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 14 (of 18)


Gang-of-Four Patterns
Creational Structural Behavioral
Singleton Adapter Chain of responsibility
Factory method Bridge Command
Abstract factory Decorator Mediator
Prototype Façade Memento
Flyweight Observer
Proxy State
Strategy
Template Method
*Builder *Composite *Interpreter
*Iterator
*Visitor
* Not to be covered in the module
CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 15 (of 18)
Review Questions

 What is a pattern?
 Why are patterns useful?
 Who uses a pattern?
 When are patterns applicable?
 Where are patterns applicable?

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 17 (of 18)


Question and Answer Session

Q&A

CT070-3-3 - Design Patterns Design Patterns – An Introduction Slide 18 (of 18)

You might also like