CSC 480 Software Engineering

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.
CSE3308/CSC Software Engineering: Analysis and DesignLecture 5B.1 Software Engineering: Analysis and Design - CSE3308 Patterns CSE3308/CSC3080/DMS/2000/12.
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,
. Plab – Tirgul 12 Design Patterns. Design Patterns u The De-Facto Book on Design Patterns:
© O. Nierstrasz, O. Greevy, A. Kuhn P2 — Clients and Servers 8.1 Roadmap  Generics  Abstract Factory  Annotations  Model-Driven Engineering.
March Ron McFadyen1 Design Patterns In software engineering, a design pattern is a generally repeatable solution to a commonly-occurring problem.
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.
Behavioral Patterns  Behavioral patterns are patterns whose purpose is to facilitate the work of algorithmic calculations and communication between classes.
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.
Creational Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
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.
CSC 480 Software Engineering Design With Patterns.
Programmeerimine Delphi keskkonnas MTAT Programmeerimine Delphi keskkonnas MTAT Jelena Zaitseva
Design Patterns Introduction
CSC 480 Software Engineering Design With Patterns.
CS 210 Proxy Pattern Nov 16 th, RMI – A quick review A simple, easy to understand tutorial is located here:
Chapter 8 Object Design Reuse and Patterns. More Patterns Abstract Factory: Provide manufacturer independence Builder: Hide a complex creation process.
CS 5150 Software Engineering Lecture 16 Program Design 3.
Reference – Object Oriented Software Development Using Java - Jia COP 3331 Object Oriented Analysis and Design Chapter 10 – Patterns Jean Muhammad.
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.
Design Patterns Creational Patterns. Abstract the instantiation process Help make the system independent of how its objects are created, composed and.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
GRASP – Designing Objects with Responsibilities
Design Patterns: MORE Examples
Software Design Refinement Using Design Patterns
Abstract Factory Pattern
Design Patterns: Brief Examples
The Object-Oriented Thought Process Chapter 15
Chapter 10 Design Patterns.
Software Design Patterns
Factory Patterns 1.
Introduction to Design Patterns
Design Patterns Introduction
Instructor: Dr. Hany H. Ammar
Design Patterns with C# (and Food!)
object oriented Principles of software design
Abstract Factory Pattern
Intent (Thanks to Jim Fawcett for the slides)
Design Patterns - A few examples
Software Engineering Lecture 7 - Design Patterns
Design Patterns Outline
Informatics 122 Software Design II
Object Oriented Design Patterns - Creational Patterns
Patterns.
CSC 480 Software Engineering
Ms Munawar Khatoon IV Year I Sem Computer Science Engineering
DESIGN PATTERNS : Introduction
Introduction to Design Patterns
Informatics 122 Software Design II
Design by Abstraction (Continuation) CS 3331 Spring 2005
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 behavioral object 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.

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.

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

Example The java.awt.Component class Name in Command Pattern Actual Name Command Component ConcreteCommand MyTankPanel execute() paintComponent() state myTank, 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 behavioral object 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.

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.

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

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

The FACTORY METHOD Pattern creational class 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.

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 Pattern Actual Name Creator Collection Product Iterator factorMethod() iterator() ConcreteCreator Any specific Collection class ConcreteProduct Any specific Iterator class (which is often anonymous)

The ABSTRACT FACTORY Pattern creational object 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.

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 Pattern Actual Name AbstractFactory AbstractTankFactory AbstractProduct AbstractTank (may be broken down to tank body, canon, and shell, etc) factorMethod() createTank() ConcreteFactory EET1TankFactory, MyGameTankFactory ConcreteProduct EET1Tank, MyGameTank

Composite Design Pattern