A Brief Introduction to Design Patterns

Slides:



Advertisements
Similar presentations
Design Patterns.
Advertisements

Design Patterns based on book of Gang of Four (GoF) Erich Gamma, Richard Helm, Ralph Johnson, and John VlissidesGang of Four (GoF) Elements of Reusable.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
 Recent researches show that predicative programming can be used to specify OO concepts including classes, objects, interfaces, methods, single and multiple.
Observer Method 1. References Gamma Erich, Helm Richard, “Design Patterns: Elements of Reusable Object- Oriented Software” 2.
Design Patterns for Object Oriented systems CSC 515 Ashwin Dandwate.
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
Design Patterns William A. Hoffman NYU OOP Class.
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Design Patterns Discussion of pages: xi-11 Sections: Preface, Forward, Chapter
Design Patterns.
Implementing Design Patterns Using Java St. Louis Java Special Interest Group Eric M. Burke Object Computing, Inc. Presented on July 9, 1998 (updated July.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Introduction To System Analysis and Design
Introduction to Design Patterns 1CS Computer Science II.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
Introduction to Design Patterns 1CS Computer Science II.
Pattern Hatching - John Vlissides Pages 85 – 101 Todd Anderson
Behavioral Design Patterns Morteza Yousefi University Of Science & Technology Of Mazandaran 1of 27Behavioral Design Patterns.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns IX Interpreter, Mediator, Template Method recap.
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
1 What is OO Design? OO Design is a process of invention, where developers create the abstractions necessary to meet the system’s requirements OO Design.
1 A Brief Introduction to Design Patterns Based on materials from Doug Schmidt 1.
Design Model Lecture p6 T120B pavasario sem.
1 Design Patterns Object-Oriented Design. 2 Design Patterns 4Reuse of design knowledge and experience 4Common in many engineering disciplines 4Avoids.
05/26/2004www.indyjug.net1 Indy Java User’s Group May Knowledge Services, Inc.
CPSC 871 John D. McGregor Module 5 Session 1 Design Patterns.
Proxy, Observer, Symbolic Links Rebecca Chernoff.
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Design Pattern Catalog - Page L3-1 PS95&96-MEF-L10-1 Dr. M.E. Fayad Creationa.
Security Patterns Template and Tutorial - Darrell M. Kienzle, Ph.D., Matthew C. Elder, Ph.D., David S. Tyree, James Edwards-Hewitt Presented by Dan Frohlich.
Design Patterns: Elements of Reusable Object- Orientated Software Gamma, Helm, Johnson, Vlissides Presented By: David Williams.
Design Patterns. 1 Paradigm4 Concepts 9 Principles23 Patterns.
Design Patterns Introduction
CS251 – Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 و ابتغ فيما آتاك الله الدار.
Design Patterns in Context ©SoftMoore ConsultingSlide 1.
Introduction to Design Patterns 1CS Computer Science II.
1 Good Object-Oriented Design Dr. Radu Marinescu Lecture 4 Introduction to Design Patterns.
The Observer Design Pattern Author :Erich Gamma, et al. Source :Elements of Reusable Object-Oriented Software Speaker : Chiao-Ping Chang Advisor : Ku-Yaw.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
1 Lecture Material Design Patterns Visitor Client-Server Factory Singleton.
GRASP – Designing Objects with Responsibilities
Design Patterns: MORE Examples
COMP2110 Software Design in lecture 14 Patterns(1) /Detailed Design
Design Patterns: Brief Examples
The Object-Oriented Thought Process Chapter 15
Software Design Patterns
Design Patterns Lecture part 2.
Object-Oriented Software Engineering Using UML, Patterns, and Java,
Introduction to Design Patterns
Design Patterns Introduction
Chapter 5: Object Oriented Analysis and Design
Software Design and Architecture
Design Patterns.
Observer Design Pattern
Object-Oriented Design
Service-centric Software Engineering
Web Programming Language
Informatics 122 Software Design II
Patterns.
Introduction to the Unified Modeling Language
Object oriented analysis and design
CS 8532: Advanced Software Engineering
What to Expect from Design Patterns
Advanced ProgramMING Practices
Advanced ProgramMING Practices
Informatics 122 Software Design II
Software Design Lecture : 27.
Presentation transcript:

A Brief Introduction to Design Patterns Based on materials from Doug Schmidt

Object-oriented design OOD methods emphasize design notations Fine for specification, documentation But OOD is more than just drawing diagrams Good draftsmen, good designers Good OO designers rely on lots of experience At least as important as syntax Most powerful reuse is design reuse Match problem to design experience OO systems exhibit recurring structures that promote: abstraction, flexibility, modularity, elegance

What is a design pattern? Codify design decisions and best practices for solving recurring problems Not software libraries Not packaged solutions Templates that must be recognized and adapted for a particular use

Four basic parts Name Problem Solution Trade-offs of application

Example: Observer pattern

Observer pattern components [1/2]

Observer pattern components [2/2]

Design patterns goals Codify good design distill & generalize experience aid to novices & experts alike Give design structures explicit names common vocabulary reduced complexity greater expressiveness Capture & preserve design information articulate design decisions succinctly improve documentation Facilitate restructuring/refactoring patterns are interrelated additional flexibility

GoF design patterns GoF:  Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides Scope: domain over which a pattern applies Purpose: reflects what a pattern does

Design pattern template [1/2] Intent short description of the pattern & its purpose Also Known As Any aliases this pattern is known by Motivation motivating scenario demonstrating pattern’s use Applicability circumstances in which pattern applies Structure graphical representation of the pattern using modified UML notation Participants participating classes and/or objects & their responsibilities

Design pattern template [2/2] Collaborations how participants cooperate to carry out their responsibilities Consequences the results of application, benefits, liabilities Implementation pitfalls, hints, techniques, plus language-dependent issues Sample Code sample implementations in C++, Java, C#, Smalltalk, C, etc. Known Uses examples drawn from existing systems Related Patterns discussion of other patterns that relate to this one

UML/OMT notation

Observer design pattern [1/3] Intent define a one-to-many dependency between objects so that when one object changes state, all dependents are notified & updated Applicability an abstraction has two aspects, one dependent on the other a change to one object requires changing untold others an object should notify unknown other objects Structure

Observer design pattern [2/3] class ProxyPushConsumer : public // … virtual void push (const CORBA::Any &event) { for (std::vector<PushConsumer>::iterator i (consumers.begin ()); i != consumers.end (); i++) (*i).push (event); } class MyPushConsumer : public // …. virtual void push (const CORBA::Any &event) { /* consume the event. */ }

Observer design pattern [3/3] Consequences modularity: subject & observers may vary independently extensibility: can define & add any number of observers customizability: different observers offer different views of subject unexpected updates: observers don’t know about each other update overhead: might need hints or filtering Implementation subject-observer mapping dangling references update protocols: the push & pull models registering modifications of interest explicitly Known Uses Smalltalk Model-View-Controller (MVC) InterViews (Subjects & Views, Observer/Observable) Pub/sub middleware (e.g., CORBA Notification Service, Java Messaging Service) Mailing lists

Benefits of design patterns Design reuse Uniform design vocabulary Enhance understanding, restructuring, & team communication Basis for automation Transcends language-centric biases/myopia Abstracts away from many unimportant details

Another example pattern: Template Provides a skeleton of an algorithm in a method, deferring some steps to subclasses (to avoid duplication) class Base_Class { public: // Template Method. void template_method (void) { hook_method_1 (); hook_method_2 (); // ... } virtual void hook_method_1 () = 0; virtual void hook_method_2 () = 0; }; class Derived_Class_1 : public Base_Class { virtual void hook_method_2 () { /* ... */ } class Derived_Class_2 : public Base_Class { virtual void hook_method_1 () { /* ... */ }

Yet another design pattern: adapter [1/1] When two software components (e.g., legacy code and new development or a COTS) cannot interface Adapter changes interface of one so the other can use it Adapter fills the gap b/w two interfaces No changes needed for either

Yet another design pattern: adapter [2/2] class NewTime { public: int GetTime() { return otime.get_time() * 100; } private: OriginalTime otime; }; An alternate: a wrapper

Relationship with other design concepts