. Plab – Tirgul 12 Design Patterns. Design Patterns u The De-Facto Book on Design Patterns:

Slides:



Advertisements
Similar presentations
Design Patterns.
Advertisements

Creational Design Patterns. Creational DP: Abstracts the instantiation process Helps make a system independent of how objects are created, composed, represented.
Plab – Tirgul 12 Design Patterns
Nov, 1, Design Patterns PROBLEM CONTEXT SOLUTION A design pattern documents a proven solution to a recurring problem in a specific context and its.
Design Patterns. What are design patterns? A general reusable solution to a commonly occurring problem. A description or template for how to solve a problem.
Spring 2010CS 2251 Design Patterns. Spring 2010CS 2252 What is a Design Pattern? "a general reusable solution to a commonly occurring problem in software.
Oct, 16, Design Patterns PROBLEM CONTEXT SOLUTION A design pattern documents a proven solution to a recurring problem in a specific context and.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Design Patterns.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
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.
Linzhang Wang Dept. of Computer Sci&Tech, Nanjing University The Abstract Factory Pattern.
Creational Patterns Making Objects The Smart Way Brent Ramerth Abstract Factory, Builder.
Design Patterns.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
Case Studies on Design Patterns Design Refinements Examples.
Creational Patterns (1) CS350, SE310, Fall, 2010.
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.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
Software Components Creational Patterns.
Unit 4 Object-Oriented Design Patterns NameStudent Number CAI XIANGHT082182A KYAW THU LINHT082238Y LI PENGFEIHT082220L NAUNG NAUNG LATTHT082195L PLATHOTTAM.
ECE450S – Software Engineering II
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State.
CDP-1 9. Creational Pattern. CDP-2 Creational Patterns Abstracts instantiation process Makes system independent of how its objects are –created –composed.
05/26/2004www.indyjug.net1 Indy Java User’s Group May Knowledge Services, Inc.
CSC 313 – Advanced Programming Topics. What Is the Factory Method?  Creation details hidden by AbstractCreator  Does effective job of limiting concrete.
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.
Stephenson College DP 98 1 Design Patterns by Derek Peacock.
Design Patterns Introduction
Design Patterns: Elements of Reusable Object – Oriented Software Web Apps and Services.
BEHAVIORAL PATTERNS 13-Sep-2012 Presenters Sanjeeb Kumar Nanda & Shankar Gogada.
Advanced Object-oriented Design Patterns Creational Design Patterns.
The Strategy Pattern (Behavioral) ©SoftMoore ConsultingSlide 1.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
The Abstract Factory Pattern (Creational) ©SoftMoore ConsultingSlide 1.
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
Csci 490 / Engr 596 Special Topics / Special Projects Software Design and Scala Programming Spring Semester 2010 Lecture Notes.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
Abstract Factory pattern Intent Provide an interface for creating families of related or dependent objects without specifying their concrete classes.
Factory Method. Intent/Purpose Factory Method is used to deal with a problem of creating objects without specifying the EXACT class of object that we.
Design Patterns: MORE Examples
Abstract Factory Pattern
Design Patterns: Brief Examples
Strategy Design Pattern
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
Chapter 10 Design Patterns.
Software Design Patterns
Factory Patterns 1.
Design Patterns Lecture 1
Introduction to Design Patterns
Abstract Factory Pattern
Intent (Thanks to Jim Fawcett for the slides)
Presented by Igor Ivković
More Design Patterns 1.
More Design Patterns 1.
Software Engineering Lecture 7 - Design Patterns
Object Oriented Design Patterns - Creational Patterns
CSC 480 Software Engineering
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
Strategy Design Pattern
Design Patterns Imran Rashid CTO at ManiWeber Technologies.
CSC 480 Software Engineering
Design by Abstraction (Continuation) CS 3331 Spring 2005
Presented by Igor Ivković
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
Presentation transcript:

. Plab – Tirgul 12 Design Patterns

Design Patterns u The De-Facto Book on Design Patterns:

What Is a Design Pattern? u A design pattern is a descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context. u A solution of a problem in a context. u A pattern is made by four elements:  name name  problem problem  solution solution  consequences consequences

Why a Design Pattern? u Helping new designers to have a more flexible and reusable design (description of others design experience). u Improving the documentation and maintenance of existing system by furnishing an explicit specification of class and object interactions and their intent. u Common terminology

Design Patterns classification u Creational  Abstract Factory  Factory Method  Singleton u Structural  Decorator u Behavioral  Strategy

Abstract Factory u Provides an interface for creating objects without specifying their concrete classes. u For example:  A factory allowed creating checkers pieces indirectly.  Simple switching to checkers where pieces move according to different rules.

Abstract Factory Structure AbstractFactory createA() createB() ConcreteFactory1 createA() createB() ConcreteFactory2 createA() createB() AbstractProductA ProdA2ProdA1 AbstractProductB ProdB2ProdB1 Creates Client

Notation u Part of the UML (Unified Modeling Language) Inheritance Association Aggregation Composite aggregation

Factory Method u Provides an interface by which instantiation is deferred to a subclass (or even another object). u Example:  Used in Abstract Factory, but also can be used independently.

Factory Method Structure ProductCreator method1() method2() FactoryMethod() Creates ConcreteProduct ConcreteCreator FactoryMethod()

Singleton u Ensures a single instance exists, and allows to access it. u For example:  Usually only one instance of ConcreteFactory is required.

Singleton Structure Singleton static getInstance() method1() method2() static uniqueInstance return uniqueInstance

Decorator u Attaching additional features to an object dynamically and independently. u For example:  Suppose we want to add additional behaviour to checkers pieces, e.g., counting number of moves performed or number of enemy pieces captured.

Decorator Structure Component operation() ConcreteComponent operation() Decorator operation() ConcreteDecoratorA operation() AddedBehavior () ConcreteDecoratorB operation() AddedBehavior () component->operation() component Decorator::operation() AddedBehavior()

Strategy u Encapsulates a family of algorithms, making them interchangeable. u Used when:  many related classes differ only in their behavior. Strategies provide a way to configure a class with one of many behaviors.  you need different variants of an algorithm.  an algorithm uses data that clients shouldn't know about.  a class defines many behaviors, and these appear as multiple conditional statements in it's operations. Instead of many conditionals, move related conditional branches into their own Strategy class.

Strategy Structure Context Strategy Algorithm() strategy StrategyA Algorithm() StrategyB Algorithm()