0% found this document useful (0 votes)
7 views

04 Design Patterns - An Introduction

The document introduces design patterns in software development, explaining their origins, definitions, and importance in creating reusable solutions for recurring design problems. It highlights the contributions of the 'Gang of Four' and outlines key elements of design patterns, including their role in the software development lifecycle. The learning outcomes emphasize the understanding of design patterns, their terminology, and their application in software engineering.

Uploaded by

Jonathan Chieng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

04 Design Patterns - An Introduction

The document introduces design patterns in software development, explaining their origins, definitions, and importance in creating reusable solutions for recurring design problems. It highlights the contributions of the 'Gang of Four' and outlines key elements of design patterns, including their role in the software development lifecycle. The learning outcomes emphasize the understanding of design patterns, their terminology, and their application in software engineering.

Uploaded by

Jonathan Chieng
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 22

Design Patterns

CT070-3-3 Version 0418

Design Patterns – An
Introduction
Topic & Structure of The
Lesson

• Impetus behind the use of Patterns


• The Origins of Design Patterns
• What is a Design Pattern?
• Patterns in the S/W Development Lifecycle
• Design Patterns: Essentials

CT070-3-3 - Design Patterns Introduction to Design Patterns


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 Introduction to Design Patterns Slide 2 (of 18)


Key Terms You Must Be
Able To Use
• If you have mastered this topic, you should
be able to use the following terms
correctly in your assignments and exams:
– Design pattern
– Reusable software
– Reoccurring solutions
– The ‘Gang of Four’

CT070-3-3 - Design Patterns Introduction to Design Patterns


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 Introduction to Design Patterns 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 Introduction to Design Patterns 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 Introduction to Design Patterns 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 Introduction to Design Patterns 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 Introduction to Design Patterns 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 Introduction to Design Patterns 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 Introduction to Design Patterns 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 Introduction to Design Patterns 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 Introduction to Design Patterns 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 Introduction to Design Patterns 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 Introduction to Design Patterns Slide 13 (of 18)
The ‘Gang of Four’

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


CT070-3-3 - Design Patterns Introduction to Design Patterns Slide 14 (of 18)
Gang-of-Four Patterns
Creational Structural Behavioral
Singleton Adapter Chain of responsibility
Factory method Decorator Mediator
Abstract factory Façade State
Prototype Proxy Strategy
Bridge Template Method
Flyweight

*Builder *Composite *Interpreter


*Flyweight *Iterator
*Visitor
*Command
*Observer
*Memento
* Not to be covered in the module
CT070-3-3 - Design Patterns Introduction to Design Patterns 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 Introduction to Design Patterns Slide 17 (of 18)


Summary of Main Teaching
Points

• Design patterns are tested and reusable


solutions for reoccurring design problems.
• Design patterns are considered
complementary to existing object-oriented
methodologies.
• Design patterns represent the first legitimate
attempt at design reusability.

CT070-3-3 - Design Patterns Introduction to Design Patterns Slide 15 (of 17)


Question and Answer Session

Q&A

CT070-3-3 - Design Patterns Introduction to Design Patterns Slide 18 (of 18)


What we will cover next

• Creational Pattern - Singleton

CT070-3-3 - Design Patterns Introduction to Design Patterns

You might also like