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

Slides:



Advertisements
Similar presentations
Design Patterns.
Advertisements

Lecture 9 Design Patterns CSCI – 3350 Software Engineering II Fall 2014 Bill Pine.
 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.
Observer Pattern Fall 2005 OOPD John Anthony. What is a Pattern? “Each pattern describes a problem which occurs over and over again in our environment,
05/26/2004www.indyjug.net1 Indy Java User’s Group June Knowledge Services, Inc.
Design and Programming Patterns Associated with Java Networking by Margaret Toews cs843, Spring 2003.
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
Design Patterns CS is not simply about programming
James Tam Introduction To Design Patterns You will learn about design techniques that have been successfully applied to different scenarios.
Spring 2010CS 2251 Design Patterns. Spring 2010CS 2252 What is a Design Pattern? "a general reusable solution to a commonly occurring problem in software.
Design Patterns William A. Hoffman NYU OOP Class.
Design Patterns Part IV (TIC++V2:C10) Yingcai Xiao 10/01/08.
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 Trends and Case Study John Hurst June 2005.
Design Patterns.
Software Engineering Design Patterns -- Introduction
02 - Behavioral Design Patterns – 2 Moshe Fresko Bar-Ilan University תשס"ח 2008.
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
UML - Patterns 1 Design Patterns. UML - Patterns 2 Becoming Good OO Developers Developing good OO Software is hard Takes a lot of time to take advantage.
ISP666 MVC & Design Patterns. Outline Review Event Programming Model Model-View-Controller Revisit Simple Calculator Break Design Patterns Exercise.
Introduction to Design Patterns 1CS Computer Science II.
January 12, Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
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.
GRASP: Designing Objects with Responsibilities
CS 4850: Senior Project Fall 2014 Object-Oriented Design.
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.
ECE450S – Software Engineering II
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.
Behavioural Design Patterns Quote du jour: ECE450S – Software Engineering II I have not failed. I've just found 10,000 ways that won't work. - Thomas Edison.
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Design Pattern Catalog - Page L3-1 PS95&96-MEF-L10-1 Dr. M.E. Fayad Creationa.
OBSERVER DESIGN PATTERN. Behavioral Patterns  Behavioral patterns are those patterns that are most specifically concerned with communication between.
Manali Joshi1 The Observer Design Pattern Presented By: Manali Joshi.
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
Concordia University Department of Computer Science and Software Engineering Click to edit Master title style ADVANCED PROGRAMMING PRACTICES Model View.
Design Patterns in Context ©SoftMoore ConsultingSlide 1.
L10: Model-View-Controller General application structure. User Interface: Role, Requirements, Problems Design patterns: Model – View – Controller, Observer/Observable.
CSIS 4850: CS Senior Project – Spring 2009 CSIS 4850: Senior Project Spring 2009 Object-Oriented Design.
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.
Design Patterns: MORE Examples
Software Design Patterns
A Brief Introduction to Design Patterns
Introduction to Design Patterns
Software Design and Architecture
Design Patterns.
Observer Design Pattern
Object oriented analysis and design
Advanced ProgramMING Practices
Advanced ProgramMING Practices
Presentation transcript:

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

2 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 2

3 Four basic parts 1. Name 2. Problem 3. Solution 4. Trade-offs of application 3

4 Example: Observer pattern 4

5 Observer pattern components [1/2] 5

6 Observer pattern components [2/2] 6

7 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 7

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

9 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 9

10 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 10

11 UML/OMT notation 11

12 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 12

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

14 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) ― Andrew (Data Objects & Views) ― Pub/sub middleware (e.g., CORBA Notification Service, Java Messaging Service) ― Mailing lists 14

15 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 15

16 Another example pattern: Template Provides a skeleton of an algorithm in a method, deferring some steps to subclasses 16 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 () { /*... */ } virtual void hook_method_2 () { /*... */ } };

17 Yet another design pattern: adapter 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 17

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

19 Relationship with other design concepts 19