12
CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

Embed Size (px)

Citation preview

Page 1: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

CS616: Software Engineering

Spring 2009

Design Patterns

Sami Taha

Page 2: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

Content

• Introduction

• Classification of patterns– List of patterns

• GoF Patterns Template

• Case Study: Observer pattern

Page 3: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

Introduction

• Design reuse

• Design Patterns motivation

Page 4: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

Classification of patterns

• Creational patterns the process of object creation – Singleton

• Single instance

– Factory Method– Building– Prototype

Page 5: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

Structural patterns

deal with the composition of classes or objects

• Façade– Unified interface

• Proxy– Protection– Synchronization– Count references– Cache

• Bridge• Composite

Page 6: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

Behavioral patternsThe ways classes or objects interact and distribute responsibility

• Observer • Visitor• State • Command • Strategy• Chain of Responsibility • Interpreter• Integrator• Mediator• Memento • Template Method

Page 7: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

GoF Patterns Template

• Pattern Name and classification• Intent

– What the pattern does• Motivation

– Scenario where the pattern would be useful• Applicability

– Situations to apply the design pattern• Structure

– Graphical representation• Participants

– Classes/object participating and responsibilities

Page 8: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

GoF Patterns Template cont.

• Collaborations– How the participants collaborates

• Consequences– Pros and consequences

• Implementation– Pitfalls, hints, or techniques should you be aware of

• Sample Code and Usage– Code fragment

• Known uses– Examples in real systems

Page 9: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

Case Study

• Observer Pattern– Pattern classification

• Behavioral pattern

– Motivation– Applicability

• When a change to one object requires changing others

• When an object should be able to notify other objects

Page 10: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

Case Study cont..

– Structure

Page 11: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

Case Study cont..

– Known usesThe observer pattern is implemented in many

programming libraries specially GUI toolkits

Examples

Java Swing

Boost.Signals

QT

Signal/Slot Library

.Net remoting

The standard PHP library

Page 12: CS616: Software Engineering Spring 2009 Design Patterns Sami Taha

References

• Wikipedia

• http://www.cs.mum.edu/