CS212: Object Oriented Analysis and Design Lecture 38: Design Pattern-II.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use.
Design Patterns Copyright © Vyacheslav Mukhortov, Nikita Nyanchuk-Tatarskiy, Copyright © INTEKS LLC,
Plab – Tirgul 12 Design Patterns
Design Patterns CS is not simply about programming
7M701 1 Class Diagram advanced concepts. 7M701 2 Characteristics of Object Oriented Design (OOD) objectData and operations (functions) are combined 
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
Design Patterns Based on Design Patterns. Elements of Reusable Object-Oriented Software. by E.Gamma, R. Helm, R. Johnson,J. Vlissides.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
ECE 355 Design Patterns Tutorial Part 2 (based on slides by Ali Razavi) Presented by Igor Ivković
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.
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Singleton Christopher Chiaverini Software Design & Documentation September 18, 2003.
Design Patterns.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
Design Patterns. Now you are ready for Design Patterns Design patterns are recurring solutions to software design problems you find again and again in.
Design Dan Fleck CS 421 George Mason University. What is the design phase? Analysis phase describes what the system should do Analysis has provided a.
CS 325: Software Engineering March 17, 2015 Applying Patterns (Part A) The Façade Pattern The Adapter Pattern Interfaces & Implementations The Strategy.
CSSE 374: Introduction to Gang of Four Design Patterns
Abstract Factory Design Pattern making abstract things.
Design Pattern. The Observer Pattern The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all.
Patterns in programming 1. What are patterns? “A design pattern is a general, reusable solution to a commonly occurring problem in software. A design.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
Structural Design Patterns
ECE450S – Software Engineering II
Patterns in programming1. 2 What are patterns? Answers to common design problems. A language used by developers –To discuss answers to design problems.
Introduction to Design Patterns Part 1. © Lethbridge/Laganière 2001 Chapter 6: Using design patterns2 Patterns - Architectural Architectural Patterns:
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 13 Creational Design Pattern SWE 316: Software Design and Architecture.
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
Design Pattern. Definition: A design pattern is a general reusable solution to a commonly occurring problem within a given context in software design.
ANU COMP2110 Software Design in 2004 Lecture 17Slide 1 COMP2110 in 2004 Software Design Lecture 17: Software design patterns (4) 1The Abstract Factory.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
1 Chapter 5:Design Patterns. 2 What are design pattern?  Schematic description of design solution to recurring problems in software design and,  Reusable.
CS212: Object Oriented Analysis and Design Lecture 39: Design Pattern-III.
Watching the movie the hard way…. Page 256 – Head First Design Patterns.
Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad.
CS 350 – Software Design The Adapter Pattern – Chapter 7 Gang of Four Definition: Convert the interface of a class into another interface that the client.
Singleton Pattern. Problem Want to ensure a single instance of a class, shared by all uses throughout a program Context Need to address initialization.
Overview of Creational Patterns ©SoftMoore ConsultingSlide 1.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
S.Ducasse Stéphane Ducasse 1 Adapter.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
Creational Patterns C h a p t e r 3 – P a g e 14 Creational Patterns Design patterns that deal with object creation mechanisms and class instantiation,
Presented by FACADE PATTERN
Design Patterns: MORE Examples
Design Patterns: Brief Examples
Design Patterns Spring 2017.
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
GoF Patterns (GoF) popo.
MPCS – Advanced java Programming
Design Patterns Lecture part 2.
Introduction to Design Patterns
Software Design and Architecture
JAVA Design Patterns.
object oriented Principles of software design
Presented by Igor Ivković
Introduction to Design Patterns Part 1
Informatics 122 Software Design II
Object Oriented Design Patterns - Creational Patterns
Object Oriented Design Patterns - Structural Patterns
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
SOEN 343 Software Design Computer Science and Software Engineering Department Concordia University Fall 2005 Instructor: Patrice Chalin.
CS 350 – Software Design Singleton – Chapter 21
Adapter Design Pattern
Informatics 122 Software Design II
Presented by Igor Ivković
Presentation transcript:

CS212: Object Oriented Analysis and Design Lecture 38: Design Pattern-II

Recap of Lecture 37 Design Pattern Pattern everywhere Pattern in computation Design pattern Iterator Patter Gang of Four Pattern

Outline of Lecture 38 GoF Pattern Abstract Factory Singleton Adapter

Pros of Design Patterns Help capture and disseminate expert knowledge. Promotes reuse and avoid mistakes. Provide a common vocabulary: Help improve communication among the developers. Reduce the number of design iterations: Help improve the design quality and designer productivity. Mar-15Software Engineering

Pros of Design Patterns Patterns solve software structural problems attributable to: Abstraction, Encapsulation Information hiding Separation of concerns Coupling and cohesion Separation of interface and implementation Single point of reference Divide and conquer Mar-15Software Engineering

Cons of Design Patterns Design patterns do not directly lead to code reuse. To help select the right design pattern at the right point during a design exercise Mar-15Software Engineering

Mar-15 Catalogue of Design Patterns (GoF) Software Engineering

Abstract Factory: Intent Provide an interface for creating families of objects A hierarchy that encapsulates Construction of a suite of "products" The new operator considered harmful

Abstract Factory: Problem If an application is to be portable, it needs to encapsulate platform dependencies platform : windowing system, OS, database, etc. Lots of #ifdef case statements

Abstract Factory: Discussion Abstracts the creation of families of related or dependent objects Without directly specifying their concrete classes The "factory" object has the responsibility for providing creation services for the entire platform family Clients never create platform objects directly, they ask the factory to do that for them. It is routinely implemented as a Singleton

Abstract Factory: Structure

Abstract Factory: Example

Abstract Factory: Check List Map out a matrix of "platforms" versus "products". Define a factory interface that consists of a factory method per product. Define a factory derived class for each platform that encapsulates all references to the new operator. The client should retire all references to new, and use the factory methods to create the product objects. Demonstration: abstractFactory.cpp

Singleton: Intent Ensure a class has only one instance Provide a global point of access to it. Encapsulated "just-in-time initialization“ "initialization on first use".

Singleton: Problem Application needs one, and only one, instance of an object. Lazy initialization and global access are necessary.

Singleton: Discussion Make the class of the single instance object responsible for creation, initialization, access, and enforcement. Declare the instance as a private static data member. Provide a public static member function that encapsulates all initialization code, and provides access to the instance.

Singleton: Structure Make the class of the single instance responsible for access and "initialization on first use". The single instance is a private static attribute. The accessor function is a public static method.

Singleton: Example

Singleton: Checklist Define a private static attribute in the "single instance" class. Define a public static accessor function in the class. Define all constructors to be protected or private. Clients may only use the accessor function to manipulate the Singleton. Demonstration: singleton.cpp

Mar-15 Catalogue of Design Patterns (GoF) Software Engineering

Adapter: Intent Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces. Wrap an existing class with a new interface. Impedance match an old component to a new system

Adapter: Problem An "off the shelf" component Offers compelling functionality that you would like to reuse

Adapter: Discussion Reuse has always been painful and elusive Something not quite right between the old and the new Creating an intermediary abstraction that translates Adapter functions as a wrapper or modifier of an existing class. It provides a different or translated view of that class.

Adapter: Structure

Adapter: Example Allows otherwise incompatible classes to work together Converting the interface of one class into an interface expected by the clients.

Adapter: Check list Identify the players: the client, the adaptee Identify the interface that the client requires Design a "wrapper" class that can "impedance match“ The adapter/ wrapper class "has a" instance of the adaptee class The adapter/wrapper class "maps" the client interface to the adaptee interface. The client uses (is coupled to) the new interface

Thank you Next Lecture: Design Pattern