Design Patterns

Slides:



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

1 Structural Design Patterns - Neeraj Ray. 2 Structural Patterns - Overview n Adapter n Bridge n Composite n Decorator.
18-1 Verifying Object Behavior and Collaboration Role playing – the act of simulating object behavior and collaboration by acting out an object’s behaviors.
Design Patterns
IEG3080 Tutorial 7 Prepared by Ryan.
Design Patterns CS is not simply about programming
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.
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 ( ) ( ) ( )
Katie C. O’Shea Dennis T. Tillman 11 February 2K2 Flyweight.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VI Composite, Iterator, and Visitor Patterns.
CERN – European Organization for Nuclear Research GS Department – Administrative Information Services Design Patterns in Groovy Nicolas Décrevel Advanced.
Design Patterns Ric Holt & Sarah Nadi U Waterloo, March 2010.
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Idioms and Patterns polymorphism -- inheritance and delegation idioms -- realizing.
BDP Behavioral Pattern. BDP-2 Behavioral Patters Concerned with algorithms & assignment of responsibilities Patterns of Communication between Objects.
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.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
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.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
CS 210 Adapter Pattern October 19 th, Adapters in real life Page 236 – Head First Design Patterns.
Design 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.
Introduction to Design Patterns. Questions What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared.
Creational Patterns
DESIGN PATTERNS Sanjeeb Kumar Nanda 30-Aug What is a pattern? Pattern is a recurring solution to a standard problem Each Pattern describes a problem.
DESIGN PATTERNS -BEHAVIORAL PATTERNS WATTANAPON G SUTTAPAK Software Engineering, School of Information Communication Technology, University of PHAYAO 1.
FACTORY METHOD. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
CS616: Software Engineering Spring 2009 Design Patterns Sami Taha.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns Introduction
Design Patterns SE464 Derek Rayside images from NetObjectives.com & Wikipedia.
Java Design Patterns Java Design Patterns. What are design patterns? the best solution for a recurring problem a technique for making code more flexible.
BEHAVIORAL PATTERNS 13-Sep-2012 Presenters Sanjeeb Kumar Nanda & Shankar Gogada.
Object-Oriented Programming © 2013 Goodrich, Tamassia, Goldwasser1Object-Oriented Programming.
Design Patterns Introduction “Patterns are discovered, not invented” Richard Helm.
Advanced Object-oriented Design Patterns Creational Design Patterns.
Example to motivate discussion We have two lists (of menu items) one implemented using ArrayList and another using Arrays. How does one work with these.
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.
An object's behavior depends on its current state. Operations have large, multipart conditional statements that depend on the object's state.
Design Patterns: Behavioral Design Patterns General and reusable solutions to common problems in software design Software University
PROTOTYPE. Design Pattern Space Purpose ScopeCreationalStructuralBehavioral ClassFactory MethodAdapterInterpreter Template Method ObjectAbstract factory.
The State Design Pattern A behavioral design pattern. Shivraj Persaud
7 April 2004CSci 210 Spring Design Patterns 2 CSci 210.
Overview of Behavioral Patterns ©SoftMoore ConsultingSlide 1.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns: MORE Examples
Unit II-Chapter No. : 5- design Patterns
Strategy Design Pattern
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
MPCS – Advanced java Programming
Common Design Patterns
Design Patterns Lecture part 2.
Introduction to Design Patterns
Behavioral Design Patterns
object oriented Principles of software design
Design Patterns
Software Engineering Lecture 7 - Design Patterns
Strategy Design Pattern
Strategy Pattern Jim Fawcett CSE776 – Design Patterns Fall 2014.
Presentation transcript:

Design Patterns

Builder Adapter Façade Memento Interpreter Observer Previous Design Patterns

Example system Kiva system to connect lenders with borrowers How could we use DPs to implement Kiva? How could we use DPs to implement a better Kiva???

Template method ProcessLoanTemplate + withdrawFromAccount() + depositToKiva() + notifyUser() ProcessCreditAccount + withdrawFromAccount() Breaks an algorithm into steps Children inherit and override any step they need to change Useful if a general algorithm can be modified slightly and be reused ProcessCheckingAccount + withdrawFromAccount()

Factory method Define an interface for creating an object, but let the classes that implement the interface decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses FormProcessor + generatePaperForm() + generateHtmHorm() + generatePdfForm HtmlForm PdfForm PaperForm LoanFormFactory +generateForm() Form FormRequestPage

Strategy SortListofLoans + executeStrategy() SortStrategy SortByName + executeStrategy() SortByLoanAmount + executeStrategy() Allows for the selection of algorithm at runtime

Decorator Useful for assigning behavior at runtime independently of other instances of the same class. Allows multiple decorations per class.

Composite CompositeLoanRecords + addLoanRecord() + removeLoanRecord() + saveLoanToDb() Allows for the reduction of complexity by dealing with a group of objects as a single object ILoanRecord + saveLoanToDb() CreditLoanRecord + saveLoanToDb() DebitLoanRecord + saveLoanToDb()

Allows for a separation of the algorithm and the data it works on Built on method overloading and dynamic types Visitor Basic Idea: An element has an accept() method that can take the visitor as an argument. The accept() method calls a visit() method of the visitor. The element passes itself as an argument to the visit() method. Depending on the types of the element and visitor at runtime, an the proper algorithm executes. See Wikipedia for more details.

Which pattern would you use? TemplateDecorator FactoryComposite StrategyVisitor Your system needs to be able to dynamically process payment according to what country the payment is coming from.

Which pattern would you use? TemplateDecorator FactoryComposite StrategyVisitor You’d like to build your model such that the data and algorithms running over the data are kept separate.

Which pattern would you use? TemplateDecorator FactoryComposite StrategyVisitor Your system needs to execute the same algorithm over multiple data sources of the same type.

Which pattern would you use? TemplateDecorator FactoryComposite StrategyVisitor You have three algorithms that only differ slightly.

Which pattern would you use? TemplateDecorator FactoryComposite StrategyVisitor You’d like to extend the functionality of a credit card processor to allow for customers to change their credit card at runtime.

Which pattern would you use? TemplateDecorator FactoryComposite StrategyVisitor Your system needs to issue unique membership cards to your customers. You have both elite and regular customer types.

Next for you Homework 4 is due next Monday Revise your vision statement.