05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.

Slides:



Advertisements
Similar presentations
Design Patterns.
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.
Lecture 9 Design Patterns CSCI – 3350 Software Engineering II Fall 2014 Bill Pine.
DESIGN PATTERNS OZGUR RAHMI DONMEZ.
Plab – Tirgul 12 Design Patterns
Design Patterns Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Design Patterns A brief introduction to what they are, why they are useful, and some examples of those that are commonly used.
(c) 2009 University of California, Irvine – André van der Hoek1June 13, 2015 – 21:42:16 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
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 Redesigning Applications And
Dept. of Computer Engineering, Amir-Kabir University 1 Design Patterns Dr. Noorhosseini Lecture 2.
(c) 2010 University of California, Irvine – André van der Hoek1June 29, 2015 – 08:55:05 Informatics 122 Software Design II Lecture 8 André van der Hoek.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Basic Design Patterns 1. Introduction Gabriel Mañana Ed. 453 Of. 120 Ext
PRESENTED BY SANGEETA MEHTA EECS810 UNIVERSITY OF KANSAS OCTOBER 2008 Design Patterns.
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Idioms and Patterns polymorphism -- inheritance and delegation idioms -- realizing.
Design Patterns Alan Shalloway, James Trott, Design Patterns Explained, Addison-Wesley, Gamma, Helm, Johnson, Vlissides, Design Patterns, Elements.
BDP Behavioral Pattern. BDP-2 Behavioral Patters Concerned with algorithms & assignment of responsibilities Patterns of Communication between Objects.
Design Patterns.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Design Patterns CSCI 5801: Software Engineering. Design Patterns.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
07 - OODCSC4071 Software Design ‘Requirements’ defines –The goals the system needs to satisfy. ‘Specification’ defines –The externally-observable behaviour.
ECE450S – Software Engineering II
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
CSC 480 Software Engineering Design With Patterns.
DESIGN PATTERNS COMMONLY USED PATTERNS What is a design pattern ? Defining certain rules to tackle a particular kind of problem in software development.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Design Pattern Catalog - Page L3-1 PS95&96-MEF-L10-1 Dr. M.E. Fayad Creationa.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
CS 210 Final Review November 28, CS 210 Adapter Pattern.
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.
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.
Design Patterns Introduction “Patterns are discovered, not invented” Richard Helm.
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.
Overview of Behavioral Patterns ©SoftMoore ConsultingSlide 1.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Examples (D. Schmidt et al)
Jim Fawcett CSE776 – Design Patterns Summer 2006
Design Patterns: MORE Examples
Design Patterns: Brief Examples
Chapter 10 Design Patterns.
Chapter 5:Design Patterns
Software Design Patterns
MPCS – Advanced java Programming
Introduction to Design Patterns
Design Patterns Lecture part 2.
Introduction to Design Patterns
Behavioral Design Patterns
object oriented Principles of software design
Design Patterns Satya Puvvada Satya Puvvada.
Software Engineering Lecture 7 - Design Patterns
Informatics 122 Software Design II
Informatics 122 Software Design II
Chapter 8, Design Patterns Introduction
Presentation transcript:

05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the first time Experienced designers will use solutions that have worked for them in the past. Design patterns –Systematically names, explains, and evaluates important, recurring designs in OO systems.

05 - Patterns Intro.CSC4072 Genesis Christopher Alexander, et. al. –A Pattern Language –Oxford University Press, 1977 “Each pattern describes a problem which occurs over and over again in our environment, and then describes the core of a solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice.” –Talking about buildings, bridges and towns. During the last decade, a “pattern community” has developed in the field of software design.

05 - Patterns Intro.CSC4073 Design Patterns in General Pattern name –A word or two that increases our design vocabulary Problem –Describes when to apply the pattern. Solution –Describes the elements that make up the design: Responsibilities, relationships, collaborations A general arrangement of classes –Must be adapted for each use Consequences –Results and trade-offs of applying the pattern Space & time Implementation issues Impact on flexibility, extensibility, portability

05 - Patterns Intro.CSC4074 Design Patterns Specifically Pattern name and classification Intent –What does it do? What’s its rationale Also knows as Motivation –A use scenario Applicability –In what situations can you apply it? How can you recognize these situations. Structure –UML Participants Collaborations Consequences –Trade-offs in applying this pattern Implementation –Any implementation tips when applying the pattern Sample code Known uses Related patterns

05 - Patterns Intro.CSC4075 Design Pattern Coverage In this course, we will cover a limited number of very basic design patterns. This is only a fraction of what a real expert might know.

05 - Patterns Intro.CSC4076 Design Pattern Space Purpose CreationalStructuralBehavioralStorageDistributed Scope Class Factory methodAdapter Template Base Interpreter Template Method Object File RDB Direct Object Abstract Factory Builder Prototype Singleton Adapter Bridge Composite Decorator Façade Proxy Chain of Responsibility Command Iterator Mediator Memento Flyweight Observer State Strategy Visitor OODB ProxyAttribute Factory

05 - Patterns Intro.CSC4077 Scope Class –Relationships between classes and their subclasses –No need to execute any code to set them up –Static, fixed at compile-time Object –Relies on object pointers. –Can be changed at run-time, are more dynamic.

05 - Patterns Intro.CSC4078 Purpose Creational –Concerns the process of object creation Structural –Concerns the relationships between classes and objects Behavioral –Concerns the ways objects and classes distribute responsibility for performing some task. Storage –Concerns the ways objects can be made persistent. Distributed –Concerns the ways server objects are represented on a client.

05 - Patterns Intro.CSC4079 Creational Patterns Class –Factory Method Define an interface for creating an object, but let subclasses decide which class to instantiate. Object –Abstract Factory Provide an interface for creating families of related objects without specifying their concrete classes. –Builder Separate the construction of a complex object from its representation so that the same construction process can create different representations. –Prototype Specify the kinds of objects to create using a prototypical instance, and create new objects by copying this prototype. –Singleton Ensure a class only has one instance, and provide a global point of access to it.

05 - Patterns Intro.CSC40710 Structural Patterns Class –Adapter Convert the interface of a class into another interface clients expect. –Template Base Use templated base classes to specify associations. Object –Adapter Convert the interface of a class into another interface clients expect. –Bridge Decouple an abstraction from its implementation so that the two can vary independently (run-time inheritance) –Composite Compose objects into tree structures to represent part-whole hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.

05 - Patterns Intro.CSC40711 Structural Patterns (cont’d) Object (cont’d) –Decorator Attach additional responsibilities to an object dynamically. –Façade Provide a unified interface to a set of interfaces in a subsystem. –Flyweight Use sharing to support large numbers of fine-grained objects efficiently. –Proxy Provide a surrogate or placeholder for another object to control access to it.

05 - Patterns Intro.CSC40712 Behavioral Patterns Class –Interpreter Given a language, define a representation for its grammar along with an interpreter that uses the representation to interpret sentences in the language. –Template Method Let subclasses redefine certain steps of an algorithm without changing the algorithm's structure. Object –Chain of Responsibility Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. –Command Encapsulate a request as an object. –Iterator Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. –Mediator Define an object that encapsulates how a set of objects interact.

05 - Patterns Intro.CSC40713 Behavioral Patterns (cont’d) Object (cont’d) –Memento Capture and externalize an object's internal state so that the object can be restored to this state later. –Observer When one object changes state, all its dependents are notified and updated automatically. –State Allow an object to alter its behavior when its internal state changes. The object will appear to change its class. –Strategy Define a family of algorithms, encapsulate each one, and make them interchangeable. –Visitor Represent an operation to be performed on the elements of an object structure.

05 - Patterns Intro.CSC40714 Storage Patterns Class –Object File Store and retrieve a network of objects to a sequential file. –RDB Direct Store and retrieve a network of objects to a relational database. Object –OODB Proxy Store and retrieve objects from an object-oriented database.

05 - Patterns Intro.CSC40715 Distributed Patterns Object –Attribute Factory Generate a lightweight object graph on the client-side of a client- server system.

05 - Patterns Intro.CSC40716 Relationships Between Patterns

05 - Patterns Intro.CSC40717 Finding Appropriate Objects Hard part about OOD is decomposing a system into objects. Many objects come directly from the analysis model or from the implementation space. OO designs often wind up with classes that have no such counterparts. –E.g., Composite, Strategy, Sate

05 - Patterns Intro.CSC40718 Determining Object Granularity Too large –Hard to change. –Procedural program inside an object. –Large, shared data structure. –Hard to understand Too small –Inefficiencies Copied data Method invocation overhead –Hard to understand Whatever the choice, negative consequences can be mitigated by judicious use of certain patterns: –Flyweight, Façade, Builder, Visitor, Command, …

05 - Patterns Intro.CSC40719 Using Object Interfaces Never refer to a class by name. Always use interfaces. –Callers remain unaware of the specific types they use. can extend the type structure –Callers remain unaware of the classes that implement the interfaces. can dynamically load new implementations Sometimes difficult to put into practice. –Creational patterns help a great deal.

05 - Patterns Intro.CSC40720 Inheritance v.s. Composition Rectangle getArea() Window getArea() 1 Composition –Can change implementations at run-time –Does not break encapsulation –Less “uselessly” general Rectangle getArea() Window getArea() Inheritance –Defined statically –Easier to modify sub-class (language supported) –Can affect behavior indirectly

05 - Patterns Intro.CSC40721 Delegation Can implement inheritance using delegation. Makes it easier to compose behaviours at run-time (e.g., Window can become circular at run-time) Many design patterns rely on delegation.