A reusable design concept
|
|
- Thomasine Mills
- 5 years ago
- Views:
Transcription
1 References: Xiaoping Jia, Object-Oriented Software Development Using Java;Douglas C.Schmidt, Design Pattern Case Studies with C++;Bruce E.Wampler,The Essence of Object-Oriented Programming with Java and UML;Design Patterns by Gamma et al.; Cay Horstmann, Object-Oriented Design & Patterns; 1 A reusable design concept Design patterns are reusable solutions to recurring design problems that emerge during software development Design patterns make design easier by offering solutions to common design problems Reuse brings benefits of OOP to OOD reusing design others have used successfully in the past 2 1
2 Abstract solution Design patterns are an abstract solution to a general design problem 3 Design Patterns Capture Expertise Design patterns capture expertise and facilitate its dissemination study of design patterns can shorten the path from new programmer to experienced designer design patterns offer a convenient way of documenting and transferring design skills 4 2
3 Patterns: a common vocabulary Design patterns define a common vocabulary for discussing design and architecture shared vocabulary is necessary for communication; words in vocabulary should be appropriately abstract for ideas to be communicated thinking in terms of low-level artifacts such as classes, interfaces and interactions may inhibit design and architecture ideas 5 And Finally... Design patterns demonstrate good design principles exhibit principles of encapsulation, cohesion and abstraction Design patterns are common in class libraries such as the Java API 6 3
4 Patterns are NOT: A solution to a specific problem The magical answer to all problems A substitute for design work (you still must do that yourself) Concrete classes, libraries or pre-made solutions 7 History of Design Patterns Originated in field of architecture with book by Christopher Alexander books about recurring themes in design of buildings and spaces A Pattern Language: Towns,Buildings, Construction, 1977 The Timeless Way of Building,
5 History of Design Patterns Christopher Alexander: Each pattern describes a problem which occurs over and over again in our environment, 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. 9 Alexander s Elements for Design Patterns Alexander described every pattern as having a short name a brief description of the context a long description of the problem a prescription for a solution The OO community adapted these elements for software design patterns 10 5
6 History of Design Patterns First industry conference on design patterns held in 1994 Pattern Languages of Program Design (PLoP) Gang of Four (GofF) book on design patterns published: Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson & John Vlissides 11 Design Patterns - GofF Defined a set of reusable software design patterns Three categories Creational : deal with process of creation Structural : deal with static composition and structure of classes and objects Behavioral : deal with dynamic interaction among classes and objects 12 6
7 Design Patterns - GofF Each pattern is described in the following terms: Pattern name Category : creational, structural or behavioral Problem: description of problem addressed Applicability : where pattern can be applied Structure : diagram that describes participants in the pattern & relationships among them Participants : list of classes and/or objects that participate in the pattern 13 Pattern Name Pattern name provides the common vocabulary for describing design elements to others A simple name reduces an entire problem, solution and consequences to a single term 14 7
8 Problem Each design pattern solves some discrete set of design problems and describes the set of problems that it is designed to solve 15 Solution The solution describes how the pattern will solve the problem It identifies the architecturally significant objects in the solution responsibilities and relationships that significant objects share The solution is a general one so pattern can apply to many different specific problems 16 8
9 Some Common Design Patterns Observer Adapter Iterator Singleton Strategy Factory Decorator 17 Observer Pattern Observer is an object that is interested in the model s state changes Notification is done through observers A subject can have any number of dependent observers that are notified when the subject undergoes a state change. The subject does not need to know who its observers are 18 9
10 Observer Pattern Category : Behavioral Name: Observer (Publish-Subscribe) Problem: Define a 1 to many relationship so when one object (observed) changes state, all dependents (observers) are notified, and they update themselves. Because coupling is loose, an observer can change or be added without affecting the observed or other observers. Observed object can also be modified independently of the observers. 19 Observer Pattern : Structure Subject +addobserver(obs:observer) +deleteobserver(obs:observer) +notify() observers for all o in observers {o.update()} Observer +update() ConcreteSubject +getstate() +setstate() subject ConcreteObserver +update() 20 10
11 Observer: Applicability Example of the Observer Pattern you see often: Show 3 Explorer windows with 3 different views Delete a file in one of the windows Show Spreadsheet Data is the model Charts are the view 21 Java Example of Observer Java supports Observer with the class java.util.observable and an interface java.util.observer Classes that want to change the state of the subject implement the interface and register with the subject to receive notification when the state changes 22 11
12 UML Diagram for java s Observer/Observable Observable -observers:vector -changed:boolean +addobserver(observer o) +deleteobserver(observer o) #setchanged() +notifyobservers() +notifyobservers(object arg) <<interface>> Observer update(observable obs, Object obj) Observer interface corresponds to Observer class in the Pattern Observable corresponds to the Subject class in the Pattern public voidnotifyobservers(object arg) { if (!changed) return; changed = false; for each observer o in vector observers o.update(this,arg) } 23 Model/View/Controller The Observer pattern is an integral part of the Model-View-Controller design pattern. MVC separates the three elements of a user interface application: model or data portion of the application view or display of the data controlling portion of the application control portion responsible for updating data from user input or other events updating the views when data changes is handled by the Observer design pattern (a sub-pattern of MVC) 24 12
13 Model/View/Controller MVC architecture many different views of the same data model holds information in some data structure views draw visible parts of the data in a format specific to the view a table view displays numbers in a table a graph view displays same data in a pie chart each view has a controller -- object that processes user interaction 25 Model/View/Controller Problem: separates key elements of user interface such that the application is more maintainable and extendable. A change to one element is not likely to affect other elements. New elements can be added without causing significant changes to existing elements
14 Model/View/Controller Solution: built on Observer design pattern Model is the observable object or subject Views are the observers MVC design pattern is Observer design pattern with a control component controller is the portion responsible for updating the model controller may physically be part of the view or a separate component 27 MVC Structure Model Update Change View Change Controller 28 14
15 MVC Scenario Controller tells model to insert text that user typed model notifies all views of change in the model all views repaint themselves each view asks model for the current text when repainting 29 MVC Model: Represents system with the business logic View: Displays the model Controllers: Handle user interaction and sends correct messages to the model and/or view [Mercer] 30 15
16 Model The Model's responsibilities Provide access to the state of the system Provide access to the system's functionality Can notify the view(s) that its state has changed [Mercer] 31 Controller The controller's responsibilities Accept user input Button clicks, key presses, mouse movements, slider bar changes Send messages to the model, which may in turn notify its observers Send appropriate messages to the view In Java, listeners are controllers [Mercer] 32 16
17 View The view's responsibilities Displaying the state of the model to the user At some point, the model (a.k.a. the observable) must register the views (a.k.a. observers) so the model can notify the observers that its state has changed [Mercer] 33 MVC minimizes coupling Model knows nothing about views -- except that they need to be notified of changes Views know nothing of controllers Easy to add more views to a model Easy to change controller for a view 34 17
18 Adapter Pattern The Adapter pattern solves the problem of incompatibility by transforming an incompatible interface into one that is needed. The incompatible object is wrapped inside a compatible adapter object. The adapter object holds onto an instance of the object and exposes the object through the interface that fits into your program. 35 Adapter Pattern Category : Structural Pattern name: Adapter (a.k.a. Wrapper) Problem: How to reuse incompatible objects 36 18
19 Adapter Pattern Solution: Provide an adapter class that holds a reference to the service available and implements the interface the client expects Consequences: Makes incompatible objects compatible; results in extra classes if you use inheritance or need to handle each subclass differently 37 UML for Adapter Design Pattern Client interfaceclientexpects methodclientexpects() interfaceavailable methodavailable() Adapter -adaptee:interfaceavailable methodclientexpects() ServiceAvailable public void methodclientexpects() { adaptee.methodavailable(); } 38 19
20 Adapter Example When using inheritance and substitutability, an object will not be able to plug in to your program unless it is part of the substitutability hierarchy Solution which does not use the Adapter pattern: edit the class you want to use so it inherits from the right class requires that you have the source code not practical to rewrite every class you might need to include in the hierarchy 39 Implementing an Adapter PsychiatristObject MoodyObject examine(obj:moodyobject) querymood() getmood():string HappyObject getmood():string CarefreeObject getmood():string SadObject getmood():string [Sintes example] Only MoodyObjects can be examined by Psychiatrist objects 40 20
21 Consider the Pet hierarchy Pet speak():string Pet speak():string Pet speak():string Pet speak():string Pets sometimes go to psychiatrists, but the MoodyObject hierarchy does not provide for a Pet object to be examined. So we need a Pet adapter. [Sintes] 41 PsychiatristObject +examine(obj:moodyobject) PetAdapter - pet : Pet +PetAdapter(obj:Pet) #getmood():string +querymood() HappyObject #getmood():string MoodyObject +querymood() #getmood():string CarefreeObject #getmood():string SadObject #getmood():string Pet +speak():string Pet Pet Adapter Adapter hides hides Pet Pet interface interface behind behind MoodyObject MoodyObject interface. interface. When When a request request comes comes into into PetAdapter, PetAdapter, it it delegates delegates to to the the Pet Pet instance instance as as needed. needed
22 PetAdapter.java public class PetAdapter extends MoodyObject { private Pet pet; public PetAdapter ( Pet pet ){ this.pet = pet; } protected String getmood(){ //MoodyObject requires us to implement this return pet.speak(); } } public void querymood(){ System.out.println ( getmood() ); } 43 Using PetAdapter PetAdapter dog = new PetAdapter ( new Dog() ); PetAdapter cat = new PetAdapter ( new Cat() ); PetAdapter bird = new PetAdapter ( new Bird() ); PsychiatristObject psychiatrist = new PsychiatristObject(); psychiatrist.examine( dog ); psychiatrist.examine( cat ); psychiatrist.examine( bird ); 44 22
23 Iterator Pattern Used with aggregate classes (container or collection classes) Aggregate object represents a group of related objects (e.g. java Vector) Common operation on aggregate object is iteration or sequential processing of each element 45 A tightly coupled example public void static clientcode(vector v) { Object obj = v.getfirst(); while (obj!= null) { process(obj); obj = v.getnext(); } } clientcode() is tightly coupled to the specific aggregate type Vector, even though a Vector is not necessarily required by the algorithm (could be ArrayList or other aggregate). The algorithm is also tightly coupled to the iteration implemented by class Vector
24 Iterator pattern removes coupling With Iterator pattern, clientcode can be made independent of a specific type of aggregate and independent of a specific iteration algorithm 47 Iterator Pattern Category : Behavioral Name: Iterator (a.k.a. Cursor) Problem: you want to loop over a collection of objects without becoming dependent upon the collection s implementation; if implementation of the collection or of the iteration changes, then it does not affect the client
25 Iterator Pattern : Solution Create abstract interface for iteration to be implemented by all classes that perform iteration Define abstract interface to be implemented by all aggregates. This interface should include a factory method which returns an object that implements the abstract interface for iteration. Define factory method in all aggregates which will create and return a class that implements the Iterator interface Write client code in terms of these two abstract interfaces. 49 Iterator Pattern Consequences: decoupled traversal simpler collection interface encapsulated looping logic Known uses:java s iterator and collection classes (see next slide) 50 25
26 Iterator Pattern: Structure <<interface>> Aggregate createiterator():iterator Client Factory Method <<interface>> Iterator next() isdone() currentitem(() Concrete Aggregate Concrete Iterator createiterator():iterator Spcific aggregate,such as list, linked list, etc. next() isdone() currentitem(() 51 UML Diagram of Java's Iterator and Collections <<interface>> Collection iterator():iterator <<interface>> Iterator hasnext():boolean next():object Vector iterator() LinkedList iterator() ArrayList iterator() Context Iterator hasnext():boolean next():object 52 26
27 Using Iterator Pattern public class IteratorExample() { public static void main(string[] args) { ArrayList arraylist = new ArrayList(); arraylist.add(new Integer(1)); arraylist.add(new Integer(2)); LinkedList linkedlist = new LinkedList(); linkedlist.add(new Integer(3)); linkedlist.add(new Integer(4)); } clientcode(arraylist); clientcode(linkedlist); 53 Using Iterator cont d } public static void clientcode(collection collection) { Iterator i = collection.iterator(); while (i.hasnext()) { Object obj = i.next(); String str = obj.tostring(); System.out.println(str + ); } System.out.println(); } Output:
28 Singleton Pattern Category : Creational Problem: ensure that a class has only one instance and provide global point of access to it Applicability: use where there must be exactly one instance of a class and it must be accessible to clients from a well-known access point (e.g. database) 55 Singleton Pattern Structure Singleton static getsingletoninstance() dosingletonoperation() getsingletondata() static theinstance SingletonData if (theinstance == 0) theinstance = new Singleton; return theinstance; 56 28
29 Singleton Pattern Participants : only one Singleton declares the unique instance of the class as a static variable and defines a static method getinstance() for clients to access the unique instance. 57 Singleton Pattern public class Singleton { public static Singleton getinstance() { return theinstance; } private constructor private Singleton() { //initialize instance fields } //. private static Singleton theinstance = new Singleton(); } 58 29
30 Strategy Pattern Category : behavioral Name : Strategy (a.k.a. Policy) Intent: define a family of algorithms, encapsulate each one and make them interchangeable 59 Strategy : Applicability Use Strategy pattern when many related classes differ only in behavior plotting different functions different variations of algorithm are needed sorts an algorithm uses data that clients should not know about LayoutManager in the AWT a class defines many behaviors which appear as multiple conditional statements in its methods 60 30
31 Strategy : Solution Create an abstract strategy class (or interface) and extend (or implement) it in numerous ways. Each subclass defines the same method names in different ways 61 Structure of Strategy Pattern Context strategy: Strategy contextinterface() STRATEGY <<interface>> Strategy algorithminterface() Concrete Strategy A algorithminterface() Concrete Strategy C algorithminterface() Concrete Strategy B algorithminterface() 62 31
32 Using the Strategy Pattern with Quicksort quicksort Pivot Strategy getpivot() pivotstrategy.getpivot(array,lo,hi) Select First Random Concrete Strategies Median of Three Strategy pattern resolves how to extend policies for selecting a pivot value without modifying main quicksort algorithm 63 Java Example of Strategy this.setlayout( new FlowLayout( ) ); this.setlayout( new GridLayout( ) ); In Java, a container contains a layout manager There is a default perhaps set in the constructor You can change a container's layout manager with a setlayout message [Mercer] 64 32
33 Java interface LayoutManager Java has a java.awt.layoutmanager interface Known Implementing Classes GridLayout, FlowLayout, ScrollPaneLayout Each class implements the following methods addlayoutcomponent(string name, Component comp) layoutcontainer(container parent) minimumlayoutsize(container parent) preferredlayoutsize(container parent) removelayoutcomponent(component comp) [Mercer] 65 UML Diagram of LayoutManager JPanel panel: Panel size: Dimension layoutboss: LayoutManager setlayout(lm: LayoutManager) setpreferredsize(di:dimension) <<interface>> LayoutManager addlayoutcomponent () layoutcontainer() minimumlayoutsize() implements [Mercer] GridLayout addlayoutcomponent () layoutcontainer() minimumlayoutsize() FlowLayout addlayoutcomponent () layoutcontainer() minimumlayoutsize() ScrollPaneLayout addlayoutcomponent () layoutcontainer() minimumlayoutsize() 66 33
34 Change the strategy at runtime Demonstrate LayoutControllerFrame.java private class FlowListener implements ActionListener { // There is another ActionListener for GridLayout public void actionperformed( ActionEvent evt ) { // Change the layout strategy of the JPanel // and tell it to lay itself out centerpanel.setlayout( new FlowLayout( ) ); centerpanel.validate( ); } } [Mercer] 67 Factory Method Pattern : background Java Collection interface defines Iterator iterator() Each subclass of Collection (LinkedList, etc) implements the method differently Each iterator method returns object of a class that implements Iterator interface, but implementation of subclasses are different 68 34
35 Factory Method Pattern : background If every collection had its own iterator, you wouldn t know which type of iterator to construct. For example, assume: LinkedList list =.; Iterator iter = new LinkedListIterator(list); But if LinkedList is a Collection, then we wouldn t know which iterator type to construct Collection coll = ; Iterator iter = new????(coll); 69 Factory Method Pattern : background Polymorphism saves the day: Iterator iter = coll.iterator(); calls the iterator method of the class the collection object belongs to The iterator method constructs an object of some class that implements the Iterator interface
36 Factory Method Pattern The iterator method is called a Factory Method A Factory Method can construct objects of subclasses, not just a fixed class 71 Factory Method Pattern Category : Creational Name: Factory Method Problem : provide a common interface for creating subclasses. A class needs to instantiate a derivation of another class, but doesn t know which one. Factory Method allows a derived class to make this decision
37 Factory Method : Intent GoF: Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses. 73 Factory Method : Context A type (called the creator) creates objects of another type (called the product) Subclasses of creator need to create different kinds of product objects Clients don t need to know exact type of product objects 74 37
38 Factory Method : Solution Define an abstract interface for the new object or product to be created. This type will express commonality of all products. Define an abstract class for creating the product. This type will express commonality of all creators. Define a method, called factory method, in the creator interface. 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. 75 UML Diagram for Factory Method Design Pattern <<interface>> AbstractCreator createproduct():abstractproduct <<interface>> AbstractProduct FactoryMethod ConcreteCreator createproduct():abstractproduct ConcreteProduct 76 38
39 FactoryMethod in Java The Java API has many classes with the word factory in their name: BasicIconFactory, BorderFactory, CertificateFactory, etc. Not all of these classes implement the Factory Method design pattern. In the Java API, any class that creates another class may have the word factory in its name. It may or may not follow the factory design pattern discussed here 77 Factory Method and Java Classes that implement the Factory Method design pattern follow a general template: // Visible to the client is an abstract class with the word // factory in its name. abstract public class SomethingFactory { // Clients start by calling this public static method. // This method returns a reference to a concrete //subclass of this class. The specific class created //and returned is usually determined by a system //property. public static SomethingFactory newinstance(); // This is the factory method. // Concrete subclasses will override this method and // decide the specific type of product created. public abstract AbstractProduct thefactorymethod(); }//end SomethingFactory // Also visible to the client is the abstract product interface with its own domain-specific methods. abstract public class AbstractProduct { public abstract void productmethod(); }//end AbstractProduct 78 39
40 Using Factory Method in Parsing XML A specific example of the Factory Method design pattern can be found in the Java API for XML parsing. Java defines an interface for XML parsing in a way that is independent of a specific parser implementation. A Java program that processes XML data can use parsers from different vendors without a source code change in the Java program. To facilitate this the Java XML API uses the Factory Method design pattern. 79 Parsing XML In Java before you can process an XML document you must obtain a parser. Java's API for XML parsing defines interfaces for two types of parsers: 1. SAX, and 2. DOM The class DocumentBuilderFactory is used to create a DOM parser: 80 40
41 DocumentBuilderFactory(1) // Note, some methods have been left off to simplify this example. abstract public class DocumentBuilderFactory { // This method returns a subclass of DocumentBuilderFactory based on a // system property. public static DocumentBuilderFactory newinstance(); public abstract DocumentBuilder newdocumentbuilder(); } abstract public class DocumentBuilder { public abstract Document parse(inputstream is); } 81 DocumentBuilderFactory(2) The client calls the public static method newinstance() to obtain an instance of the factory class DocumentBuilderFactory. The specific factory returned is based on properties set at runtime. The factory class returned determines what type of parser is created when the client calls the factory method newdocumentbuilder(). The interface onto the parser is defined by the abstract class DocumentBuilder
42 State Pattern Name: State Problem: Objects have state and behavior. Objects change their state based on internal and external events. If an object goes through clearly identifiable states, and the object's behavior is especially dependent on it's state, it is a good candidate for the State design pattern. 83 State Pattern : Solution Encapsulate the state-specific behavior into separate objects and have the context delegate state-specific requests to these objects
43 State Pattern : UML Diagram 85 State Pattern A separate concrete class is created for each identifiable state. State-specific behavior is encapsulated in these classes. An abstract interface is defined for these classes(abstractstate in the diagram). The context (class that has different states) holds a private reference to a state object. State-dependent methods in the context class are forwarded to the state object. Some mechanism is provided for moving between states
44 State Pattern Here are 3 options for moving between states: 1. The client of the context can take responsibility for setting the state of the context. 2. The Context can take responsibility. 3. The states can take responsibility. 87 Decorator Pattern Category : Structural Name : Decorator Problem : Goal is to add more responsibilities to an object dynamically, avoiding subclassing. Example: add scrolling to a text view. The scrolling object surrounds the text view, handles mechanics of the scroll bar, then tells text view to display itself appropriately. [GoF] 88 44
A reusable design concept Design patterns are reusable solutions to recurring design problems that emerge during software development
References: Xiaoping Jia, Object -Oriented Software Development Using Java;Douglas C.Schmidt, Design Pattern Case Studies with C++;Bruce E.Wampler,The Essence of Object-Oriented Programming with Java and
More informationA reusable design concept Design patterns are reusable solutions to recurring design problems that emerge during software development
A reusable design concept Design patterns are reusable solutions to recurring design problems that emerge during software development References: Xiaoping Jia, Object-Oriented Software Development Using
More informationLecture 13: Design Patterns
1 Lecture 13: Design Patterns Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2005 2 Pattern Resources Pattern Languages of Programming Technical conference on Patterns
More informationPattern Resources. Lecture 25: Design Patterns. What are Patterns? Design Patterns. Pattern Languages of Programming. The Portland Pattern Repository
Pattern Resources Lecture 25: Design Patterns Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2003 Pattern Languages of Programming Technical conference on Patterns
More informationGoals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming
Goals of Lecture Lecture 27: OO Design Patterns Cover OO Design Patterns Background Examples Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2001 April 24, 2001 Kenneth
More informationCSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich
CSCD01 Engineering Large Software Systems Design Patterns Joe Bettridge Winter 2018 With thanks to Anya Tafliovich Design Patterns Design patterns take the problems consistently found in software, and
More informationIdioms and Design Patterns. Martin Skogevall IDE, Mälardalen University
Idioms and Design Patterns Martin Skogevall IDE, Mälardalen University 2005-04-07 Acronyms Object Oriented Analysis and Design (OOAD) Object Oriented Programming (OOD Software Design Patterns (SDP) Gang
More informationDesign Patterns. Definition of a Design Pattern
Design Patterns Barbara Russo Definition of a Design Pattern A Pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem,
More informationSoftware Engineering - I An Introduction to Software Construction Techniques for Industrial Strength Software
Software Engineering - I An Introduction to Software Construction Techniques for Industrial Strength Software Chapter 9 Introduction to Design Patterns Copy Rights Virtual University of Pakistan 1 Design
More informationTopics in Object-Oriented Design Patterns
Software design Topics in Object-Oriented Design Patterns Material mainly from the book Design Patterns by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides; slides originally by Spiros Mancoridis;
More informationOutline. Design Patterns. Observer Pattern. Definitions & Classifications
Outline Design Patterns Definitions & Classifications Observer Pattern Intent Motivation Structure Participants Collaborations Consequences Implementation 1 What is a Design Pattern describes a problem
More informationAn Introduction to Patterns
An Introduction to Patterns Robert B. France Colorado State University Robert B. France 1 What is a Pattern? - 1 Work on software development patterns stemmed from work on patterns from building architecture
More informationDesign Patterns. An introduction
Design Patterns An introduction Introduction Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. Your design should be specific to the problem at
More informationAn Introduction to Patterns
An Introduction to Patterns Robert B. France Colorado State University Robert B. France 1 What is a Pattern? Patterns are intended to capture the best available software development experiences in the
More informationTuesday, October 4. Announcements
Tuesday, October 4 Announcements www.singularsource.net Donate to my short story contest UCI Delta Sigma Pi Accepts business and ICS students See Facebook page for details Slide 2 1 Design Patterns Design
More informationSoftware Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.
Software Design Patterns Jonathan I. Maletic, Ph.D. Department of Computer Science Kent State University J. Maletic 1 Background 1 Search for recurring successful designs emergent designs from practice
More informationbe used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate
UNIT 4 GRASP GRASP: Designing objects with responsibilities Creator Information expert Low Coupling Controller High Cohesion Designing for visibility - Applying GoF design patterns adapter, singleton,
More informationCPSC 310 Software Engineering. Lecture 11. Design Patterns
CPSC 310 Software Engineering Lecture 11 Design Patterns Learning Goals Understand what are design patterns, their benefits and their drawbacks For at least the following design patterns: Singleton, Observer,
More informationDr. Xiaolin Hu. Review of last class
Review of last class Design patterns Creational Structural Behavioral Abstract Factory Builder Factory Singleton etc. Adapter Bridge Composite Decorator Façade Proxy etc. Command Iterator Observer Strategy
More informationDesign Patterns. Gunnar Gotshalks A4-1
Design Patterns A4-1 On Design Patterns A design pattern systematically names, explains and evaluates an important and recurring design problem and its solution Good designers know not to solve every problem
More informationDesign Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011
Design Patterns Lecture 1 Manuel Mastrofini Systems Engineering and Web Services University of Rome Tor Vergata June 2011 Definition A pattern is a reusable solution to a commonly occurring problem within
More informationDESIGN PATTERN - INTERVIEW QUESTIONS
DESIGN PATTERN - INTERVIEW QUESTIONS http://www.tutorialspoint.com/design_pattern/design_pattern_interview_questions.htm Copyright tutorialspoint.com Dear readers, these Design Pattern Interview Questions
More informationUsing Design Patterns in Java Application Development
Using Design Patterns in Java Application Development ExxonMobil Research & Engineering Co. Clinton, New Jersey Michael P. Redlich (908) 730-3416 michael.p.redlich@exxonmobil.com About Myself Degree B.S.
More informationIngegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1
Ingegneria del Software Corso di Laurea in Informatica per il Management Design Patterns part 1 Davide Rossi Dipartimento di Informatica Università di Bologna Pattern Each pattern describes a problem which
More informationWhat is Design Patterns?
Paweł Zajączkowski What is Design Patterns? 1. Design patterns may be said as a set of probable solutions for a particular problem which is tested to work best in certain situations. 2. In other words,
More informationCS 349 / SE 382 Design Patterns. Professor Michael Terry January 21, 2009
CS 349 / SE 382 Design Patterns Professor Michael Terry January 21, 2009 Today s Agenda More demos! Design patterns CS 349 / SE 382 / 2 Announcements Assignment 1 due Monday at 5PM! CS 349 / SE 382 / 3
More informationDesign patterns for graphical user interface applications
Design patterns for graphical user interface applications Prof.Asoc. Alda Kika Department of Informatics Faculty of Natural Sciences University of Tirana Outline Pattern Concept Design pattern in computer
More informationMore on Design. CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson
More on Design CSCI 5828: Foundations of Software Engineering Lecture 23 Kenneth M. Anderson Outline Additional Design-Related Topics Design Patterns Singleton Strategy Model View Controller Design by
More informationThe GoF Design Patterns Reference
The GoF Design Patterns Reference Version.0 / 0.0.07 / Printed.0.07 Copyright 0-07 wsdesign. All rights reserved. The GoF Design Patterns Reference ii Table of Contents Preface... viii I. Introduction....
More informationApplying the Observer Design Pattern
Applying the Observer Design Pattern Trenton Computer Festival Professional Seminars Michael P. Redlich (908) 730-3416 michael.p.redlich@exxonmobil.com About Myself Degree B.S. in Computer Science Rutgers
More informationSoftware Reengineering Refactoring To Patterns. Martin Pinzger Delft University of Technology
Software Reengineering Refactoring To Patterns Martin Pinzger Delft University of Technology Outline Introduction Design Patterns Refactoring to Patterns Conclusions 2 The Reengineering Life-Cycle (1)
More informationEPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns
EPL 603 TOPICS IN SOFTWARE ENGINEERING Lab 6: Design Patterns Links to Design Pattern Material 1 http://www.oodesign.com/ http://www.vincehuston.org/dp/patterns_quiz.html Types of Design Patterns 2 Creational
More informationWhat is a Pattern? Lecture 40: Design Patterns. Elements of Design Patterns. What are design patterns?
What is a Pattern? Lecture 40: Design Patterns CS 62 Fall 2017 Kim Bruce & Alexandra Papoutsaki "Each pattern describes a problem which occurs over and over again in our environment, and then describes
More informationSOFTWARE PATTERNS. Joseph Bonello
SOFTWARE PATTERNS Joseph Bonello MOTIVATION Building software using new frameworks is more complex And expensive There are many methodologies and frameworks to help developers build enterprise application
More informationSlide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D
Slide 1 Design Patterns Prof. Mirco Tribastone, Ph.D. 22.11.2011 Introduction Slide 2 Basic Idea The same (well-established) schema can be reused as a solution to similar problems. Muster Abstraktion Anwendung
More information4.1 Introduction Programming preliminaries Constructors Destructors An example... 3
Department of Computer Science Tackling Design Patterns Chapter 4: Factory Method design pattern Copyright c 2016 by Linda Marshall and Vreda Pieterse. All rights reserved. Contents 4.1 Introduction.................................
More informationLectures 24 and 25 Introduction to Architectural Styles and Design Patterns
Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns Software Engineering ITCS 3155 Fall 2008 Dr. Jamie Payton Department of Computer Science University of North Carolina at Charlotte
More informationModellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico
Modellistica Medica Maria Grazia Pia INFN Genova Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico 2002-2003 Lezione 8 OO modeling Design Patterns Introduction Creational Patterns Software
More informationFacade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004
Facade and Adapter Comp-303 : Programming Techniques Lecture 19 Alexandre Denault Computer Science McGill University Winter 2004 March 23, 2004 Lecture 19 Comp 303 : Facade and Adapter Page 1 Last lecture...
More informationSummary of the course lectures
Summary of the course lectures 1 Components and Interfaces Components: Compile-time: Packages, Classes, Methods, Run-time: Objects, Invocations, Interfaces: What the client needs to know: Syntactic and
More informationIntroduction and History
Pieter van den Hombergh Fontys Hogeschool voor Techniek en Logistiek September 15, 2016 Content /FHTenL September 15, 2016 2/28 The idea is quite old, although rather young in SE. Keep up a roof. /FHTenL
More informationCSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich
CSCD01 Engineering Large Software Systems Design Patterns Joe Bettridge Winter 2018 With thanks to Anya Tafliovich Design Patterns Design patterns take the problems consistently found in software, and
More informationTrusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout
1 Last update: 2 November 2004 Trusted Components Reuse, Contracts and Patterns Prof. Dr. Bertrand Meyer Dr. Karine Arnout 2 Lecture 5: Design patterns Agenda for today 3 Overview Benefits of patterns
More informationDesign Patterns 2. Page 1. Software Requirements and Design CITS 4401 Lecture 10. Proxy Pattern: Motivation. Proxy Pattern.
Proxy : Motivation Design s 2 It is 3pm. I am sitting at my 10Mbps connection and go to browse a fancy web page from the US, This is prime web time all over the US. So I am getting 100kbps What can you
More informationDesign Patterns. CSC207 Fall 2017
Design Patterns CSC207 Fall 2017 Design Patterns A design pattern is a general description of the solution to a well-established problem using an arrangement of classes and objects. Patterns describe the
More informationDesign Patterns. CSC207 Winter 2017
Design Patterns CSC207 Winter 2017 Design Patterns A design pattern is a general description of the solution to a well-established problem using an arrangement of classes and objects. Patterns describe
More informationObject-Oriented Design
Object-Oriented Design Lecturer: Raman Ramsin Lecture 20: GoF Design Patterns Creational 1 Software Patterns Software Patterns support reuse of software architecture and design. Patterns capture the static
More informationThe Strategy Pattern Design Principle: Design Principle: Design Principle:
Strategy Pattern The Strategy Pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it. Design
More informationSDC Design patterns GoF
SDC Design patterns GoF Design Patterns The design pattern concept can be viewed as an abstraction of imitating useful parts of other software products. The design pattern is a description of communicating
More informationInheritance. EEC 521: Software Engineering. Dealing with Change. Polymorphism. Software Design. Changing requirements Code needs to be flexible
Inheritance EEC 521: Software Engineering Software Design Design Patterns: Decoupling Dependencies 10/15/09 EEC 521: Software Engineering 1 Inheritance is the mechanism by which one class can acquire properties/responsibilities
More informationDesign Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)
Design Pattern CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.) A. Design Pattern Design patterns represent the best practices used by experienced
More informationDesign Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns
Introduction o to Patterns and Design Patterns Dept. of Computer Science Baylor University Some slides adapted from slides by R. France and B. Tekinerdogan Observations Engineering=Problem Solving Many
More informationCPS122 Lecture: Design Patterns Last revised March 20, 2012
CPS122 Lecture: Design Patterns Last revised March 20, 2012 Objectives 1. To introduce and illustrate the idea of design patterns 2. To introduce some key design patterns students have used or will use:
More informationObject Oriented Design & Patterns. Part 1
Object Oriented Design & Patterns Part 1 1 Design Patterns Derived from architectural patterns: rules for design of buildings describe common problems, solutions to those problems OO design patterns convenient
More informationCS560. Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995
CS560 Lecture: Design Patterns II Includes slides by E. Gamma et al., 1995 Classification of GoF Design Pattern Creational Structural Behavioural Factory Method Adapter Interpreter Abstract Factory Bridge
More informationWhat is Design Patterns?
Paweł Zajączkowski What is Design Patterns? 1. Design patterns may be said as a set of probable solutions for a particular problem which is tested to work best in certain situations. 2. In other words,
More informationCS342: Software Design. November 21, 2017
CS342: Software Design November 21, 2017 Runnable interface: create threading object Thread is a flow of control within a program Thread vs. process All execution in Java is associated with a Thread object.
More informationObject-Oriented. Design Patterns
CSC 335: Object-Oriented Programming and Design Object-Oriented Another question to total 150 points Design Patterns Outline Overview of Design Patterns Four Design Patterns Iterator Decorator Strategy
More informationObject Oriented Methods with UML. Introduction to Design Patterns- Lecture 8
Object Oriented Methods with UML Introduction to Design Patterns- Lecture 8 Topics(03/05/16) Design Patterns Design Pattern In software engineering, a design pattern is a general repeatable solution to
More informationDevelopment and Implementation of Workshop Management System Application to Explore Combing Multiple Design Patterns
St. Cloud State University therepository at St. Cloud State Culminating Projects in Computer Science and Information Technology Department of Computer Science and Information Technology 5-2015 Development
More informationhttps://www.lri.fr/~linaye/gl.html
Software Engineering https://www.lri.fr/~linaye/gl.html lina.ye@centralesupelec.fr Sequence 3, 2017-2018 1/50 Software Engineering Plan 1 2 3 4 5 2/50 Software Engineering ground Evolution of Program 3/50
More informationDesign patterns. OOD Lecture 6
Design patterns OOD Lecture 6 Next lecture Monday, Oct 1, at 1:15 pm, in 1311 Remember that the poster sessions are in two days Thursday, Sep 27 1:15 or 3:15 pm (check which with your TA) Room 2244 + 2245
More information11/12/12. Objectives DESIGN PATTERNS. Design Pattern. Defined Design Patterns. Applying Design Patterns. Motivating Example
Objectives Design Patterns Open up Eclipse DESIGN PATTERNS Nov 12, 2012 Sprenkle - CSCI209 1 Nov 12, 2012 Sprenkle - CSCI209 2 Design Pattern General reusable solution to a commonly occurring problem in
More informationDesign Patterns. CSC207 Fall 2017
Design Patterns CSC207 Fall 2017 Design Patterns A design pattern is a general description of the solution to a well-established problem using an arrangement of classes and objects. Patterns describe the
More informationCoordination Patterns
Coordination Patterns 1. Coordination Patterns Design Patterns and their relevance for Coordination Oscar Nierstrasz Software Composition Group Institut für Informatik (IAM) Universität Bern oscar@iam.unibe.ch
More informationOODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00
OODP Session 4 Session times PT group 1 Monday 18:00 21:00 room: Malet 403 PT group 2 Thursday 18:00 21:00 room: Malet 407 FT Tuesday 13:30 17:00 room: Malet 404 Email: oded@dcs.bbk.ac.uk Web Page: http://www.dcs.bbk.ac.uk/~oded
More informationFactory Method Pattern Creational. » Define an interface for creating an object but lets subclasses decide the specific class to instantiate
Factory Method Pattern Creational Intent» Define an interface for creating an object but lets subclasses decide the specific class to instantiate > Delegate creation to the appropriate subclass Also known
More informationDesign Patterns גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון
Design Patterns גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון 2 Problem: Reusability in OO Designing OO software is hard, and designing reusable OO software is even harder: Software should be specific
More information2.1 Design Patterns and Architecture (continued)
MBSE - 2.1 Design Patterns and Architecture 1 2.1 Design Patterns and Architecture (continued) 1. Introduction 2. Model Construction 2.1 Design Patterns and Architecture 2.2 State Machines 2.3 Timed Automata
More information2.1 Design Patterns and Architecture (continued)
MBSE - 2.1 Design Patterns and Architecture 1 2.1 Design Patterns and Architecture (continued) 1. Introduction 2. Model Construction 2.1 Design Patterns and Architecture 2.2 State Machines 2.3 Abstract
More information3 Product Management Anti-Patterns by Thomas Schranz
3 Product Management Anti-Patterns by Thomas Schranz News Read above article, it s good and short! October 30, 2014 2 / 3 News Read above article, it s good and short! Grading: Added explanation about
More informationDesign of Software Systems (Ontwerp van SoftwareSystemen) Design Patterns Reference. Roel Wuyts
Design of Software Systems (Ontwerp van SoftwareSystemen) Design Patterns Reference 2015-2016 Visitor See lecture on design patterns Design of Software Systems 2 Composite See lecture on design patterns
More informationCHAPTER 6: CREATIONAL DESIGN PATTERNS
CHAPTER 6: CREATIONAL DESIGN PATTERNS SESSION III: BUILDER, PROTOTYPE, SINGLETON Software Engineering Design: Theory and Practice by Carlos E. Otero Slides copyright 2012 by Carlos E. Otero For non-profit
More informationSocket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.
Gang of Four Software Design Patterns with examples STRUCTURAL 1) Adapter Convert the interface of a class into another interface clients expect. It lets the classes work together that couldn't otherwise
More informationSoftware Engineering I (02161)
Software Engineering I (02161) Week 11 Assoc. Prof. Hubert Baumeister DTU Compute Technical University of Denmark Spring 2017 Recap I Software Development Processes (cont.) I Project Planning I Design
More informationFoundations of Software Engineering Design Patterns -- Introduction
Foundations of Software Engineering Design Patterns -- Introduction Fall 2016 Department of Computer Science Ben-Gurion university Based on slides of: Nurit Gal-oz, Department of Computer Science Ben-Gurion
More informationPatterns of learning
Design patterns Patterns of learning Suppose we want to learn how to play chess. First, we need to learn the basic rules. Then we need to learn the basic strategy/ principles (value of pieces, etc.). To
More informationCHAPTER 6: CREATIONAL DESIGN PATTERNS
CHAPTER 6: CREATIONAL DESIGN PATTERNS SESSION I: OVERVIEW OF DESIGN PATTERNS, ABSTRACT FACTORY Software Engineering Design: Theory and Practice by Carlos E. Otero Slides copyright 2012 by Carlos E. Otero
More informationApplying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3
Applying Some Gang of Four Design Patterns CSSE 574: Session 5, Part 3 Steve Chenoweth Phone: Office (812) 877-8974 Cell (937) 657-3885 Email: chenowet@rose-hulman.edu Gang of Four (GoF) http://www.research.ibm.com/designpatterns/pubs/ddj-eip-award.htm
More informationRefining the Observer Pattern: The Middle Observer Pattern
Refining the Observer Pattern: The Middle Observer Pattern Pablo Iaría - iariap@sol.info.unlp.edu.ar Ulises Chesini - uliche@sol.info.unlp.edu.ar Abstract The refinement presented in this paper incorporates
More informationApplying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1
Applying Design Patterns to accelerate development of reusable, configurable and portable UVCs. Accellera Systems Initiative 1 About the presenter Paul Kaunds Paul Kaunds is a Verification Consultant at
More informationLecture 19: Introduction to Design Patterns
Lecture 19: Introduction to Design Patterns Software System Design and Implementation ITCS/ITIS 6112/8112 091 Fall 2008 Dr. Jamie Payton Department of Computer Science University of North Carolina at Charlotte
More informationCPS122 Lecture: Design Patterns Last revised March 7, 2017
CPS122 Lecture: Design Patterns Last revised March 7, 2017 Objectives 1. To introduce and illustrate the idea of design patterns 2. To introduce some key design patterns students have used or will use:
More informationWhat is Design Patterns?
Paweł Zajączkowski What is Design Patterns? 1. Design patterns may be said as a set of probable solutions for a particular problem which is tested to work best in certain situations. 2. In other words,
More informationCSE 70 Final Exam Fall 2009
Signature cs70f Name Student ID CSE 70 Final Exam Fall 2009 Page 1 (10 points) Page 2 (16 points) Page 3 (22 points) Page 4 (13 points) Page 5 (15 points) Page 6 (20 points) Page 7 (9 points) Page 8 (15
More informationKeywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.
Comparative Study In Utilization Of Creational And Structural Design Patterns In Solving Design Problems K.Wseem Abrar M.Tech., Student, Dept. of CSE, Amina Institute of Technology, Shamirpet, Hyderabad
More informationDesign patterns. Valentina Presutti courtesy of Paolo Ciancarini
Design patterns Valentina Presutti courtesy of Paolo Ciancarini Agenda What are design patterns? Catalogues of patterns Languages of patterns Two case studies: design with patterns Software Architectures
More informationCocoa Design Patterns. Erik M. Buck October 17, 2009
Cocoa Design Patterns Erik M. Buck October 17, 2009 Topics n What is a design pattern? n Why Focus on design patterns? n What is the Model View Controller design pattern? n Using MVC n When wouldn t you
More informationProgrammazione. Prof. Marco Bertini
Programmazione Prof. Marco Bertini marco.bertini@unifi.it http://www.micc.unifi.it/bertini/ Design patterns Design patterns are bug reports against your programming language. - Peter Norvig What are design
More informationLecture Material. Design Patterns. Visitor Client-Server Factory Singleton
Lecture Material Design Patterns Visitor Client-Server Factory Singleton 1 Design Patterns Pattern A named generalization describing the elements and relationships of a solution for a commonly occurring
More informationDesign Patterns. it s about the Observer pattern, the Command pattern, MVC, and some GUI. some more
Lecture: Software Engineering, Winter Semester 2011/2012 some more Design Patterns it s about the Observer pattern, the Command pattern, MVC, and some GUI Design Pattern *...+ describes a problem which
More informationBrief Note on Design Pattern
Brief Note on Design Pattern - By - Channu Kambalyal channuk@yahoo.com This note is based on the well-known book Design Patterns Elements of Reusable Object-Oriented Software by Erich Gamma et., al.,.
More informationChapter 5: Patterns and GUI Programming
Chapter Topics Chapter 5: Patterns and GUI Programming The Pattern Concept The ITERATOR Pattern The OBSERVER Pattern Layout Managers and the STRATEGY Pattern Components, Containers, and the COMPOSITE Pattern
More informationChapter 8, Object Design: Reusing Pattern Solutions
Object-Oriented Software Engineering Using UML, Patterns, and Java Chapter 8, Object Design: Reusing Pattern Solutions Application Objects and Solution Objects Application objects, also called domain objects,
More informationDesign Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1
What is a Design Pattern? Each pattern Describes a problem which occurs over and over again in our environment,and then describes the core of the problem Novelists, playwrights and other writers rarely
More informationDesign Patterns. Dr. Rania Khairy. Software Engineering and Development Tool
Design Patterns What are Design Patterns? What are Design Patterns? Why Patterns? Canonical Cataloging Other Design Patterns Books: Freeman, Eric and Elisabeth Freeman with Kathy Sierra and Bert Bates.
More informationDesign pa*erns. Based on slides by Glenn D. Blank
Design pa*erns Based on slides by Glenn D. Blank Defini6ons A pa#ern is a recurring solu6on to a standard problem, in a context. Christopher Alexander, a professor of architecture Why would what a prof
More informationProduced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar
Design Patterns MSc in Communications Software Produced by Eamonn de Leastar (edeleastar@wit.ie) Department of Computing, Maths & Physics Waterford Institute of Technology http://www.wit.ie http://elearning.wit.ie
More informationThe Design Patterns Matrix From Analysis to Implementation
The Design Patterns Matrix From Analysis to Implementation This is an excerpt from Shalloway, Alan and James R. Trott. Design Patterns Explained: A New Perspective for Object-Oriented Design. Addison-Wesley
More informationDesign Patterns. CSCE Lecture 17-10/28/2015 (Partially adapted from Head First Design Patterns by Freeman, Bates, Sierra, and Robson)
Design Patterns CSCE 740 - Lecture 17-10/28/2015 (Partially adapted from Head First Design Patterns by Freeman, Bates, Sierra, and Robson) OO Design Exercise: Building a Better Duck Duck quack() swim()
More information