CSC 480 Software Engineering Design With 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

 Recent researches show that predicative programming can be used to specify OO concepts including classes, objects, interfaces, methods, single and multiple.
Design Patterns CMPS Design Patterns Consider previous solutions to problems similar to any new problem ▫ must have some characteristics in common.
OOP Design Patterns Chapters Design Patterns The main idea behind design patterns is to extract the high level interactions between objects and.
March Ron McFadyen1 Design Patterns In software engineering, a design pattern is a generally repeatable solution to a commonly-occurring problem.
Plab – Tirgul 12 Design Patterns
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,
March Ron McFadyen1 Design Patterns In software engineering, a design pattern is a generally repeatable solution to a commonly-occurring 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.
Design patterns Observer,Strategi, Composite,Template (Chap 5, 6)
1 Object Oriented Design & Patterns Part 1. 2 Design Patterns Derived from architectural patterns: –rules for design of buildings –describe common problems,
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.
Introduction to software design patterns For CSE 3902 By: Matt Boggus.
Vrije Universiteit amsterdamPostacademische Cursus Informatie Technologie Idioms and Patterns polymorphism -- inheritance and delegation idioms -- realizing.
Design Patterns Discussion of pages: xi-11 Sections: Preface, Forward, Chapter
Design Patterns.
Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
Creational Patterns (1) CS350, SE310, Fall, 2010.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Software Engineering 1 Object-oriented Analysis and Design Applying UML and Patterns An Introduction to Object-oriented Analysis and Design and Iterative.
January 12, Introduction to Design Patterns Tim Burke References: –Gamma, Erich, et. al. (AKA, The Gang of Four). Design Patterns: Elements of Reusable.
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
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.
Object-Oriented Design Principles and Patterns. © 2005, James R. Vallino2 How Do You Design? What principles guide you when you create a design? What.
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.
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.
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
CS 4233 Review Feb February Review2 Outline  Previous Business – My.wpi.edu contains all grades to date for course – Review and contact.
Programmeerimine Delphi keskkonnas MTAT Programmeerimine Delphi keskkonnas MTAT Jelena Zaitseva
CS 151: Object-Oriented Design October 15 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
Design Patterns Introduction
Using Software Design Patterns Bill Anderson. About me Fox developer since 1987 Fox developer since 1987 Program Director, Los Angeles Visual Foxpro Developers.
CSC 480 Software Engineering Design With Patterns.
Design Patterns for Games Proceedings of the 33 rd SIGCSE technical symposium on Computer Science Education Melisa Tyira SE510.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
Session 30 Final Review. Final Details Wednesday, December 14 at 8 AM Wright 5 (same classroom) Final will be comprehensive Open book Open notes Test.
Five Minute Design Patterns Doug Marttila Forest and the Trees May 30, 2009 Template Factory Singleton Iterator Adapter Façade Observer Command Strategy.
Duke CPS Programming Heuristics l Identify the aspects of your application that vary and separate them from what stays the same ä Take what varies.
Class Relationships Lecture Oo08 Polymorphism. References n Booch, et al, The Unified Modeling Language User Guide, Chapt 10 p.125 n Fowler & Scott, UML.
1 Good Object-Oriented Design Dr. Radu Marinescu Lecture 4 Introduction to Design Patterns.
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Design Patterns: MORE Examples
Software Design Refinement Using Design Patterns
Design Patterns: Brief Examples
The Object-Oriented Thought Process Chapter 15
Chapter 10 Design Patterns.
Software Design Patterns
Introduction to Design Patterns
Design Patterns Introduction
Software Design and Architecture
Design Patterns with C# (and Food!)
object oriented Principles of software design
Software Engineering Lecture 7 - Design Patterns
Informatics 122 Software Design II
Object Oriented Design Patterns - Creational Patterns
Patterns.
CSC 480 Software Engineering
DESIGN PATTERNS : Introduction
Introduction to Design Patterns
Informatics 122 Software Design II
CSC 480 Software Engineering
CSC 480 Software Engineering
Presentation transcript:

CSC 480 Software Engineering Design With Patterns

The Essence of Patterns Each pattern describes a problem which occurs over and over again, and then describes the core of the 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. Christopher Alexander

What Is a Design Pattern? In general, a pattern has four essential elements – The pattern name – abstracts a design problem, its solutions, and consequences (vocabulary) – The problem – explains the context and describes how to represent algorithm as objects – The solution – describes the elements that make up the design, their relationships, responsibilities, and collaborations – The consequences – the results and trade-offs of applying the pattern (evaluation)

The Catalog of GoF Patterns Design patterns are first classified by their purpose – Creational – the process of object creation – Structural – composition of classes and objects – Behavioral – the ways in which classes and objects interact and distribute responsibilities The second criterion is scope – Class – static, fixed at compile-time – Object – more dynamic, changeable at run-time

Design Pattern Space

The COMMAND Pattern The COMMAND pattern defines a method that all subclasses needs to do, while deferring details of the algorithms to each subclass to allow for additional information being provided. behavioral object

Solution Define a command interface with a method to execute the command. Supply methods in the command interface type to manipulate the state of the command objects. Each concrete command class implement the command interface. To invoke the command, call the execute method.

Structure Client state Concrete Command execute() > Command execute()

Example The java.awt.Component class Name in Command PatternActual Name CommandComponent ConcreteCommandMyTankPanel execute()paintComponent() statemyTank, road, shell

How to Memorize? The Hollywood Principle Don’t call us, we’ll call you. When we design with the Command pattern, we’re telling subclasses the same thing Other patterns (to be discussed shortly) that make use of the Hollywood Principle – Observer – Factory method

The OBSERVER Pattern The OBSERVER pattern provides a mechanism to monitor and notify changes in an source object to one or more objects (known as the “observers”) that need to update themselves with the latest state from the source. behavioral object

Solution Define an observer interface type. All concrete observer classes must implement this interface type. The subject (source) maintains a collection of observer objects. The subject class supplies the method(s) for attaching observers. Whenever an event (change) occurs, the subject notifies all observers, which in turn update themselves.

Structure Subject Concrete Observer notify() > Observer notify() attach()

Example The java.awt.event.ActionListener interface (as well as other XxxListener interfaces) Name in Command PatternActual Name Subject JButton Observer ActionListener ConcreteObserverSpecific classes implementing ActionListener attach() addActionListener() notify() actionPerformed()

The FACTORY METHOD Pattern The Factory Method pattern defines an interface for creating an object, but lets subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. creational class

Context A type (the creator) creates objects of another type (the product). Subclasses of the creator type need to create different kinds of product objects. Clients do not need to know the exact type of product objects.

Solution Define a creator type that expresses the commonality of all creators. Define a product type that expresses the commonality of all products. Define a method, called the factory method, in the creator type. The factory method yields a product object. Each concrete creator class implements the factory method so that it returns an object of a concrete product class.

Structure

Example The java.util.Collection interface (or the java.util.Iterable interface as available since Java5) Name in Command PatternActual Name Creator Collection Product Iterator factorMethod() iterator() ConcreteCreatorAny specific Collection class ConcreteProductAny specific Iterator class (which is often anonymous)

The ABSTRACT FACTORY Pattern Similar to the FACTORY METHOD, the ABSTRACT FACTORY pattern defines methods that construct a family of related products. A concrete factory class is needed for each family of related products. creational object

Solution Define an AbstractFactory interface type. All concrete Factory classes must implement this interface type. Define two or more product types that expresses the commonality of family of related products. Define a create method for each kind of related products in the family in the AbstractFactory type. Each create method yields a product object in the desired type. Each concrete factory class implements all set of the factory methods so that it returns an set of related product objects for the specific style.

Structure

Example The java.awt.event.ActionListener interface (as well as other XxxListener interfaces) Name in Command PatternActual Name AbstractFactoryAbstractTankFactory AbstractProductAbstractTank (may be broken down to tank body, canon, and shell, etc) factorMethod()createTank() ConcreteFactoryEET1TankFactory, MyGameTankFactory ConcreteProductEET1Tank, MyGameTank

Composite Design Pattern