The Factory Method Pattern
|
|
- Frank Wheeler
- 5 years ago
- Views:
Transcription
1 The Factory Method Pattern Intent: Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory method lets a class defer instantiation to subclasses. 1
2 The Factory Method Pattern Structure 2
3 Applicability Use the Factory Method pattern in any of the following situations: A class can not anticipate the class of objects it must create A class wants its subclasses to specify the objects it creates 3
4 Participants The classes and/objects participating in this pattern are: Product: defines the interface for the type of objects the factory method creates ConcreteProduct: implements the Product interface Creator: declares the factory method, which returns an object of type Product. Creator may also define a default implementation of the factory method that returns a default ConcreteProduct object. may call the factory method to create a Product object ConcreteCreater: Overrides the factory method to return an instance of a ConcreteProduct 4
5 Collaborations Collaborations: Creator relies on its subclasses to implement the factory method so that it returns an instance of the appropriate ConcreteProduct 5
6 Consequences Benefits Code is made more flexible and reusable by the elimination of instantiation of application-specific classes Code deals only with the interface of the Product class and can work with any ConcreteProduct class that supports this interface Liabilities Clients might have to subclass the Creator class just to instantiate a particular ConcreteProduct 6
7 Implimentation Issues Creator can be abstract or concrete Should the fatory method be able to create multiple kinds of products? If so, then the fatory method has a parameter (possibly used in an if-else!) to decide what object to create. 7
8 The Abstract Factory Pattern Intent: Provide an interface for creating families of related or dependent objects without specifying their concrete classes. The Abstract Factory pattern is very similar to the Factory pattern. One difference between the two is that with the Abstract Factory pattern, a class delegates the responsibility of object instantiation to another object via composition whereas the Factory pattern uses inheritance and relies on a subclass to handle the desired object instatiation. Actually, the delegated object frequently uses factory method to perform the instantiation. 8
9 The Abstract Factory Structure 9
10 The Abstract Factory Participants AbstractFactory: Declares an interface for operations that create abstract products objects. ConcreteFactory: Implements the operations to create concrete product objects. AbstractProduct: Declares an interface for a type of product object. 10
11 ConcreteProduct: Defines a product object to be created by the corresponding concrete factory. Implements the AbstractProduct interface. Client: Uses only interfaces declared by the AbstractFactory and AbstractProduct classes.s. 11
12 Applicability Use when A system should be independent of how its products are created, composed and represented A system should be configured with one of multiple families of products A family of related product objects is designed to be used together, and you need to enforce this constraint You want to provide a class library of products, and you want to reveal just their interfaces, not their implementation 12
13 Collaborations 1. A single instance of each different Concrete Factory is created at run time. These Concrete Factories are used to create product objects having different implementations. The client should use a different concrete factory for each different product object. 2. The Abstract Factory defers the creation of the product object to its Concrete Factory subclass 13
14 Normal usage: the client software would create a concrete implementation of the abstract factory and then use the generic interfaces to create the concrete objects that are part of the theme. Separate the details of implementation of a set of objects from its general usage. 14
15 Consequences The Abstract Factory pattern has the following consequences: Advantages: It isolates concrete classes because a factory encapsulates the responsibility and the process of creating product objects. - isolates clients from implementation classes. - Clients manipulate instances through their abstract interfaces It makes exchanging products families easy since the class of a concrete factory appears only once in an application. It promotes consistency among products since the application is using objects from only one family at a time. 15
16 Disadvantages: Extending the abstract factory is not easy because the AbstractFactory interface fixes the set of products that can be created. So new products requires extending the factory interface which involves changing the AbstractFactory class and all its subclasses. 16
17 Abstract Fcatory - an example [2001 exam] A software system for handling student results has these requirements: 1. There are two classes of students: Arts and Science. Each Faculty will have its own set of records, one for all Arts students, the other for all Science students. 2. A student's record contains an ID number, type of degree, and marks for all subjects taken this semester. 3. Arts students records have their major discipline (a string like "History"). 4. Arts students only take Arts subjects; Science students only take Science subjects. 5. Each arts student takes 4 subjects, each science student takes only Every subject has a name and a subject code. 7. Arts subjects have an exam mark and an essay mark, each out of Science subjects have an exam mark out of 100 and two assignment marks 9. Every subject has a final mark that can be computed by a function called final. 10. The same method called grade is used for all subjects for calculating the grade from the final mark. 17
18 Students and subjects Student ID,degree RM = new ArtsRecordMaker() // or new ScienceRecordMaker() s = RM.CreateStudent() -- includes setnsubjs for sc in [1..s.NSubjs] s.subject[sc]= RM.CreateSubject() ArtsStudt major SciStudt Subject <<create>> ArtsRecordMaker CreateStudent() CreateSubject() AbstractRecordMaker CreateStudent() CreateSubject() ArtsSubjt exam essay final() ScienceRecordMaker CreateStudent() CreateSubject() ScienceSubjt exam asg1 asg2 final() 18
19 ProductA1 ArtsStudt major Abstract ProductA ConcreteFactory1 Student ID,degree ArtsRecordMaker CreateStudent() CreateSubject() AbstractFactory AbstractRecordMaker CreateStudent() CreateSubject() ProductA2 SciStudt ProductB1 ArtsSubjt exam essay final() ConcreteFactory2 ScienceRecordMaker CreateStudent() CreateSubject() Abstract Factory Abstract ProductB Subject ProductB2 ScienceSubjt exam asg1 asg2 final() 19
20 Example: Different animal world for computer game: Video Game: In this game, different animal objects are created. Requirements: We need to create different animal objects with different characteristics. The way in which the animals are created must be the same from the clients point of view. The animals are divided into two classes: Herbivore and Carnivore. The animals are grouped together by continent, for example, AfricanAnimal, AmericanAnimal, AustralianAnimal, etc. The way in which the animal objects member functions are accessed must be the same for all animals from the point of view of the client. Classes: Abstract Product1 Herbivore Abstract Product2 Carnivore Concrete Product1 Wildebeest & Bison Concrete Product2 Lion & Wolf Draw or sketch the solution on blackboard, relate to the UML diagram of Abstract factory pattern for class discussion. 20
21 The Facade Pattern Description: Provide a unified interface to a set of interfaces in a subsystem. Facade defines a higher-level interface that makes the subsystem easier to use. 21
22 Before using the Facade Pattern 22
23 After using the Facade Pattern 23
24 The Facade Pattern Structure 24
25 Applicability Use the Facade pattern: Need to provide a simple interface to a complex system. This is good enough for most clients; more sophisticated clients can look beyond the facade. Need to decouple a subsystem from its clients and other subsystems, thereby promoting subsystem independence and portability. Need to provide an interface to a software layer 25
26 The Facade pattern provides a simple, easy-to-use interface to a complicated software subsystem. Simplifies coupling with this subsystem. Allows changes to subsystem implementation (including changing the names of classes, adding or taking away classes) without affecting clients. Effectively allows higher level object orientation. The whole subsystem now looks like a single class to the outside world. Another way to think of this is as a form of encapsulation. Here instead of hiding some data, we're hiding all the details of a whole subsystem (abstract module). This is higher level encapsulation. With lots of use of this pattern, there could possibly be a class representing each Abstract Module (in Parnas' terminology), acting as a Facade for all the classes in its implementation. Is this a good way to go about developing a large system? A bit like the old ``top-down design''. 26
27 Consequences Advantages It hides the implementation of the subsystem from clients, making the subsystem easier to use. It promotes weak coupling between the subsystems and its clients.this allows you to change the classes that comprise the subsystem without affecting the clients. It reduces compilation dependencies in large software system. 27
28 It simplifies porting systems to other platforms, because it's less likely that building one subsystem requires building all others. Note that Facade does not add any functionality, it just simplifies interfaces. Disadvantage: It does not prevent clients from accessing the underlying classes. 28
29 Example: A compiler Stream BytecodeStream CodeGenerator Compiler Compile() Scanner Parser PnodeBuilder Token Symbol Pnode Invocations StatementNode ExpressionNode RISCCodegenerator StackMachineCodegenerator 29
30 The Iterator Pattern Provide a way to access the elements of an aggregate object sequentially without exposing its underlying representation. An aggregate object is an object that contains other objects for the purpose of grouping those objects as a unit. It is also called a container or a collection. Examples are a linked list and a hash table. 30
31 The classes and/or objects participating in this pattern are: Iterator (AbstractIterator) defines an interface for accessing and traversing elements. ConcreteIterator (Iterator) implements the Iterator interface. keeps track of the current position in the traversal of the aggregate. Aggregate (AbstractCollection) defines an interface for creating an Iterator object 31
32 ConcreteAggregate (Collection) implements the Iterator creation interface to return an instance of the proper ConcreteIterator. 32
33 The Iterator Pattern Structure 33
34 Applicability Use the Iterator pattern: To support traversals of aggregate objects without exposing their internal representations. To support multiple, concurrent traversals of aggregate objects. To provide a uniform interface for transversing different aggregate structures (that is, to support polymorphic iteration). 34
35 Consequences Advantages: Simplifies the interface of the Aggregate by not polluting it with traversal methods. Supports multiple, concurrent traversals Supports variant traversal techniques. Disadvantages: None. 35
36 Implimentation issues: Who controls the iteration? The client => more flexible: called an external iterator. The iterator itself => called an interior iterator. Who defines the traversal algorithm? The iterator => more common: easer to have variant traversal techniques. The aggregate => iterator only keeps state of the iteration. 36
37 How robust is the iterator? It can be dangerous to modify an aggregate while you are traversing it. If elements are added or deleted from the aggregate you might end up accessing an element twice or missing it completely. A simple solution is to copy the aggregate and traverse the copy, but that is too expensive to do in general. Example: Look at Java Implementation of Iterator, the java.util.enumeration interface act as iterator interface. 37
38 The Command Pattern Intent: Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. 38
39 The Command Pattern Structure 39
40 The classes and/or objects participating in this pattern are: Command: declares an interface for executing an operation. ConcreteCommand: defines a binding between a Receiver object and an action. implements Execute by invoking the corresponding operation(s) on Receiver. Client (CommandApp): creates a ConcreteCommand object and sets its receiver. 40
41 Invoker (User): asks the command to carry out the request. Receiver: knows how to perform the operations associated with carrying out the request. 41
42 Applicability When to Use the Command Pattern: When you need an action as a parameter. When you want to implement a callback function capability. When you need to specify, queue, and execute requests at different times. When you need to support undo. When you need to support logging changes. 42
43 When you structure a system around high-level operations built on primitive operations. A Transactions encapsulates a set of changes to data. Systems that use transaction often can use the command pattern. When you need to support a macro language. 43
44 Consequences Command decouples the object that invokes the operation from the one that knows how to perform it. It is easy to add new commands, because you do not have to change existing classes. You can assemble commands into a composite object. 44
45 Implementation Issues: How intelligent should a command be? A command can have a wide range of abilities. At one extreme it merely defines a binding between a receiver and the actions that carry out the request. At the other extreme it implements everything itself without delegating to a receiver at all, (in this case, it is useful for a command that creates independent application). Supporting undo and redo (to reverse execution). Avoiding error accumulation in the undo process. 45
46 What the Command Pattern does: When two objects communicate, often one object is sending a command to the other object to perform a particular function. The most common way to accomplish this is for the first object (the "issuer") to hold a reference to the second (the "recipient"). The issuer executes a specific method on the recipient to send the command. But what if the issuer is not aware of, or does not care who the recipient is? That is, the issuer simply wants to abstractly issue the command? The Command design pattern encapsulates the concept of the command into an object. The issuer holds a reference to the command object rather than to the recipient. The issuer sends the command to the command object by executing a specific method on it. The command object is then responsible for dispatching the command to a specific recipient to get the job done. 46
47 Example: Situation: A GUI system has several buttons that perform various actions. We want to have menu items that perform the same action as its corresponding button. Draw or sketch the solution on blackboard, relate to the UML diagram of Command Pattern for class discussion. Solution: Have an action listener for each paired button and menu item. Keep the required actions in the actionperformed() method of this one action listener. This solution is essentially the command pattern with ConcreteCommand classes that perform the actions themselves. 47
48 Class Problem: Scenario: We want to run a backup operation every hour and a disk status operation every ten minutes. But we do not want the class to know the details of these operations or the objects that provide them. We want to decouple the class that schedules the execution of these methods with the classes that actually provide the behavior we want to execute. (We want to write a class that can periodically execute one or more methods of various objects.) Classes: TaskMinder, TaskEntry, Task, BackupTask, DiskStatusTask, etc. Draw or sketch the solution on blackboard, relate to the UML diagram of Command Pattern for class discussion. 48
49 The State Pattern Intent: Allow an object to alter its behavior when its internal state changes. The object will appear to change its class. 49
50 The State Pattern Structure 50
51 The classes and/or objects participating in this pattern are: Context: defines the interface of interest to clients. maintains an instance of a ConcreteState subclass that defines the current state. State: defines an interface for encapsulating the behavior associated with a particular state of the Context. Concrete State: each subclass implements a behavior associated with a state of Context. 51
52 Applicability Use the State pattern in either of the following cases: An object's behavior depends on its state, and it must change its behavior at run-time depending on that state. Operations have large, multipart conditional statements that depend on the object's state. Often, several operations will contain this same conditional structure. 52
53 Consequences It localize state-specific behavior and partitions for different states. It makes state transitions explicit. State objects can be shared. 53
54 Implementation issues Who defines the state transitions? The Context class => ok for simple situations. The ConcreteState classes => generally more flexible, but causes implementation dependencies between the ConcreteState classes. The State Pattern does not specify which participants defines the criteria for state transitions. When are the ConcreteState objects created? (Creating and destroying State objects.) Create ConcreteState objects as needed (avoids creating objects that won't be used). Create all Concrete objects once and have the Context object keep references to them (it is better when state change occur rapidly; it might be inconvenient, because the Context must keep reference to all states that might be entered). 54
55 Using dynamic inheritance Changing the delegation target at run-time effectively changes the inheritance structure. It lets objects change their behavior and amounts to changing their class. 55
56 Class problem: Situation: Consider a simplified version of the Post Office Protocols used to download from a mail server. Simple POP (SPOP) supports the following command: USER username The USER command with a username must be the first command issued. PASS password The PASS command with a password or the QUIT command must come after USER. If the username and password are valid, then the user can use other commands. 56
57 LIST <message number> The LIST command returns the size of all messages in the mail box. If the optional message number is specified, then it returns the size of that message. RETRV <message number> The RETRV command retrieves all messages in the mail box. If the optional message number is specified, then it retrieves that message. QUIT The QUIT command updates the mail box to reflect transactions taken, then logs the user out. Draw or sketch the solution on blackboard, relate to the UML diagram of State Pattern for class discussion. 57
58 The Chain of Responsibility Pattern Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects and pass the request along the chain until an object handles it. With the Chain of responsibility pattern, you create a chain of objects that examine a request. Each object in turn examines the request and handles it, or passes it on to the next objects in the chain. 58
59 The Chain Responsibility Pattern Structure Sample Object Structure 59
60 Participants Handler Defines the interface for handling the requests May implement the successor link ConcreteHandler Handles requests it is responsible for Can access its successor Handles the request if it can do so, otherwise it forwards the request to its successor Client (ChainApp) initiates the request to a ConcreteHandler object on the chain 60
61 Collaborations Client instantiates the Handlers, their connections, and when needed, fires off the chain of action. Handlers take action if they can, otherwise they pass it off to the next successive Handler. Final handler takes action regardless. 61
62 Consequences Reduced coupling between sender and receiver no knowledge of each other Added flexibility in assigning responsibilities to objects (Chain of handlers can be modified dynamically). Not guaranteed that request will be handled 62
63 Applicability When to use: When more than on object may handle a request, and the handler isn't known a priori When you want to issue a request to one of several objects without specifying the receiver explicitly When the set of objects that can handle a request should be specified dynamically 63
64 Implementation Issues The successor chain Use existing links in the program The concrete handlers may already have pointers to their successors, so just use them Define new links Give each handler a link to its successor 64
65 Representing Requests Each request is hard-coded convenient and safe not flexible limited to the fixed set of requests defined by handler Unique handler with parameters more flexible but it requires conditional statements for dispatching request less type-safe to pass parameters Unique handler with Request object parameter Subclasses extend rather than overwrite the handler method 65
66 Class Problem: Situation: Suppose that you are writing software to monitor a security system. Physically, the security system consists of sensing devices (motion detectors, smoke detectors...) that transmit status information to a computer. The computer's job is to log all status information, maintain a display showing current status information and transmit alarms in the event of an emergency. To keep things simple, your monitoring program should instantiate an object for every sensor it is to monitor. This provides a simple way to model each sensor's state. To ensure scalability, an object responsible for an individual sensor should not assume anything about its environment, except that it is at the bottom level of a hierarchical organization. The organization will include objects corresponding to such real world things such as rooms, areas, floors and buildings. Directly modeling the real world provides a straightforward way to display the status of different parts of buildings. It also allows the interpretation of a sensor's state to be based on its environment. For example, if the temperature of a closed room exceeds 180 F then you may want the fire sprinklers in just that room to turn on. If the temperature in an open area of a warehouse exceeds 150 F you may want to turn on the fire sprinklers over that area and the adjacent areas. On the other hand, if the temperature in a freezer exceeds 30 F, to may want to sound an alarm to let people know that that freezer is getting too warm. In all these cases, the object that models a sensor does not decide what to do with the state of the sensor. Instead, it delegates that decision to an object at a higher level of the hierarchy that has more contextual knowledge. Such objects either decide what to do about a notification or pass it on to the object that is organizationally above it. Draw UML diagram for it. 66
67 Physical Security object diagram 67
68 Class diagram showing the general organization of the Chain of Responsibility pattern: 68
69 Solution: See the next slide 69
70 70
71 The Mediator Pattern Description Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly. 71
72 The Mediator Pattern Structure 72
73 The Mediator Pattern Structure Classes Objects 73
74 The classes and/or objects participating in this pattern are: Mediator Defines an interface for communicating with Colleague objects ConcreteMediator Implements cooperative behavior by coordinating Colleague objects Knows and maintains its colleagues Colleague defines an interface for communicating with the Mediator class ConcreteColleague classes (OneColleague, NextColleague) Each Colleague class knows its Mediator object Each colleague communicates with its mediator whenever it would have otherwise communicated with another colleague. 74
75 Applicability When to use the Mediator Pattern Use the Mediator Pattern to centralise complex communications and control between related objects. When a set of objects communicate in a well-defined but complex ways When reusing an object is difficult because it refers to and communicates with many other objects When a behavior that's distributed between several classes should be customizable without a lot of subclassing Complex interaction exists. 75
76 Consequences Limits subclassing Decouples colleagues Simplifies object protocols Abstracts how objects cooperate Centralizes control 76
77 Implementation issues How do Colleagues and Mediators Communicate? Explicit methods in Mediator Generic change method Generic change method overloaded 77
78 Class Problem: Scenario: Font resources are shared data structures, shared between applications and the GUI system. These font resources maybe quite large and complex. If the system had a lot of components(either ActiveX or JavaBeans), each component would have to allocate, manage and destroy their font resources. Every time each of these components repaint, they would have to create the font, select it into the device context, use it, select it out and then delete it. Imagine a container having a number of such components each one doing this on every repaint. A separate mediator object can assist here by maintaining ownership of a reuseable pool of font resources on an application or system-wide basis without affecting the application or the GUI system. It would also help if the mediator object could 'cache' frequently used fonts. This mediator object can thus act as a centralised point of access. Draw a UML diagram for this scenario for class discussion. 78
EPL 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 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 informationDesign Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011
Design Patterns Lecture 2 Manuel Mastrofini Systems Engineering and Web Services University of Rome Tor Vergata June 2011 Structural patterns Part 2 Decorator Intent: It attaches additional responsibilities
More informationDesign Patterns Reid Holmes
Material and some slide content from: - Head First Design Patterns Book - GoF Design Patterns Book Design Patterns Reid Holmes GoF design patterns $ %!!!! $ "! # & Pattern vocabulary Shared vocabulary
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 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 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 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 informationImplementing GUI context-sensitive help... ECE450 Software Engineering II. Implementing GUI context-sensitive help... Context-sensitive help
Implementing GUI context-sensitive help... ECE450 Software Engineering II Today: Design Patterns VIII Chain of Responsibility, Strategy, State ECE450 - Software Engineering II 1 ECE450 - Software Engineering
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 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 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 9 OO modeling Design Patterns Structural Patterns Behavioural Patterns
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 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 informationLaboratorio di Progettazione di Sistemi Software Design Pattern Creazionali. Valentina Presutti (A-L) Riccardo Solmi (M-Z)
Laboratorio di Progettazione di Sistemi Software Design Pattern Creazionali Valentina Presutti (A-L) Riccardo Solmi (M-Z) Indice degli argomenti Catalogo di Design Patterns creazionali: Abstract Factory
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 informationLecture 20: Design Patterns II
Lecture 20: Design Patterns II Software System Design and Implementation ITCS/ITIS 6112/8112 001 Fall 2008 Dr. Jamie Payton Department of Computer Science University of North Carolina at Charlotte Nov.
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 informationObject-Oriented Oriented Programming
Object-Oriented Oriented Programming Composite Pattern CSIE Department, NTUT Woei-Kae Chen Catalog of Design patterns Creational patterns Abstract Factory, Builder, Factory Method, Prototype, Singleton
More informationDesign Pattern- Creational pattern 2015
Creational Patterns Abstracts instantiation process Makes system independent of how its objects are created composed represented Encapsulates knowledge about which concrete classes the system uses Hides
More informationLast Lecture. Lecture 17: Design Patterns (part 2) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 4448/ Spring Semester, 2005
1 Lecture 17: Design Patterns (part 2) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 4448/6448 - Spring Semester, 2005 2 Last Lecture Design Patterns Background and Core Concepts Examples
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 informationObject-Oriented Design
Object-Oriented Design Lecture 20 GoF Design Patterns Behavioral Department of Computer Engineering Sharif University of Technology 1 GoF Behavioral Patterns Class Class Interpreter: Given a language,
More informationCOSC 3351 Software Design. Design Patterns Behavioral Patterns (I)
COSC 3351 Software Design Design Patterns Behavioral Patterns (I) Spring 2008 Purpose Creational Structural Behavioral Scope Class Factory Method Adapter(class) Interpreter Template Method Object Abstract
More informationDesign Patterns. Comp2110 Software Design. Department of Computer Science Australian National University. Second Semester
Design Patterns Comp2110 Software Design Department of Computer Science Australian National University Second Semester 2005 1 Design Pattern Space Creational patterns Deal with initializing and configuring
More informationCreational Design Patterns
Creational Design Patterns Creational Design Patterns Structural Design Patterns Behavioral Design Patterns GoF Design Pattern Categories Purpose Creational Structural Behavioral Scope Class Factory Method
More informationObject Oriented Paradigm
Object Oriented Paradigm Ming-Hwa Wang, Ph.D. Department of Computer Engineering Santa Clara University Object Oriented Paradigm/Programming (OOP) similar to Lego, which kids build new toys from assembling
More informationDesign Patterns Reid Holmes
Material and some slide content from: - Head First Design Patterns Book - GoF Design Patterns Book Design Patterns Reid Holmes GoF design patterns $ %!!!! $ "! # & Pattern vocabulary Shared vocabulary
More informationSecond Midterm Review
Second Midterm Review Comp-303 : Programming Techniques Lecture 24 Alexandre Denault Computer Science McGill University Winter 2004 April 5, 2004 Lecture 24 Comp 303 : Second Midterm Review Page 1 Announcements
More informationLast Lecture. Lecture 26: Design Patterns (part 2) State. Goals of Lecture. Design Patterns
Lecture 26: Design Patterns (part 2) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 6448 - Spring Semester, 2003 Last Lecture Design Patterns Background and Core Concepts Examples Singleton,
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 informationCreational Patterns. Factory Method (FM) Abstract Factory (AF) Singleton (SI) Prototype (PR) Builder (BU)
Creational Patterns Creational Patterns Factory Method (FM) Abstract Factory (AF) Singleton (SI) Prototype (PR) Builder (BU) Factory Method (FM) Intent: Define an interface for creating an object, but
More informationInformation systems modelling UML and service description languages
Internet Engineering Tomasz Babczyński, Zofia Kruczkiewicz Tomasz Kubik Information systems modelling UML and service description languages Overview of design patterns for supporting information systems
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 informationObject-Oriented Oriented Programming Command Pattern. CSIE Department, NTUT Woei-Kae Chen
Object-Oriented Oriented Programming Command Pattern CSIE Department, NTUT Woei-Kae Chen Command: Intent Encapsulate a request as an object thereby letting you parameterize clients with different requests
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 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 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 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 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 informationObject-Oriented Oriented Programming Factory Method Pattern Abstract Factory Pattern. CSIE Department, NTUT Woei-Kae Chen
Object-Oriented Oriented Programming Factory Method Pattern Abstract Factory Pattern CSIE Department, NTUT Woei-Kae Chen Factory Method Pattern Factory Method Pattern Creational pattern Factory Method:
More informationDesign Patterns V Structural Design Patterns, 2
Structural Design Patterns, 2 COMP2110/2510 Software Design Software Design for SE September 17, 2008 Department of Computer Science The Australian National University 19.1 1 2 Formal 3 Formal 4 Formal
More informationThe Chain of Responsibility Pattern
The Chain of Responsibility Pattern The Chain of Responsibility Pattern Intent Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain
More informationThe Chain of Responsibility Pattern. Design Patterns In Java Bob Tarr
The Chain of Responsibility Pattern The Chain of Responsibility Pattern Intent Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain
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 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 informationThink of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern
Think of drawing/diagramming editors ECE450 Software Engineering II Drawing/diagramming editors let users build complex diagrams out of simple components The user can group components to form larger components......which
More informationIntroduction to Software Engineering: Object Design I Reuse & Patterns
Introduction to Software Engineering: Object Design I Reuse & Patterns John T. Bell Department of Computer Science University of Illinois, Chicago Based on materials from Bruegge & DuToit 3e, Chapter 8,
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 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 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 informationDesign patterns. Jef De Smedt Beta VZW
Design patterns Jef De Smedt Beta VZW Who Beta VZW www.betavzw.org Association founded in 1993 Computer training for the unemployed Computer training for employees (Cevora/Cefora) 9:00-12:30 13:00-16:00
More informationSoftware Eningeering. Lecture 9 Design Patterns 2
Software Eningeering Lecture 9 Design Patterns 2 Patterns covered Creational Abstract Factory, Builder, Factory Method, Prototype, Singleton Structural Adapter, Bridge, Composite, Decorator, Facade, Flyweight,
More informationUsing Design Patterns in Education and Tutoring for the Software Systems Projects in Economic
Using Design Patterns in Education and Tutoring for the Software Systems Projects in Economic Cornelia NOVAC-UDUDEC cornelia.novac@ugal.ro Dunarea de Jos University of Galati Abstract. The paper deals
More informationDesign Patterns Lecture 2
Design Patterns Lecture 2 Josef Hallberg josef.hallberg@ltu.se 1 Patterns covered Creational Abstract Factory, Builder, Factory Method, Prototype, Singleton Structural Adapter, Bridge, Composite, Decorator,
More information6.3 Patterns. Definition: Design Patterns
Subject/Topic/Focus: Analysis and Design Patterns Summary: What is a pattern? Why patterns? 6.3 Patterns Creational, structural and behavioral patterns Examples: Abstract Factory, Composite, Chain of Responsibility
More informationDesign for change. You should avoid
Design patterns Sources Cours de Pascal Molli «A System of Pattern» Bushmann et All «Design Patterns» Gamma et All (GoF) «Applying UML and Patterns» Larman "Design Patterns Java Workbook" Steven John Metsker
More informationAppendix A - Glossary(of OO software term s)
Appendix A - Glossary(of OO software term s) Abstract Class A class that does not supply an implementation for its entire interface, and so consequently, cannot be instantiated. ActiveX Microsoft s component
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 informationPrototype Description. Interpreter. interpreter Calculator Design Rationales. Prototype Participants. Interpreter with Factory Method.
Onno van Roosmalen Pieter van den Hombergh Fontys Hogeschool voor Techniek en Logistiek October 3, 2014 Content Implementation Description with Factory Participants Implementation Description with Factory
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 informationDesign Patterns #3. Reid Holmes. Material and some slide content from: - GoF Design Patterns Book - Head First Design Patterns
Material and some slide content from: - GoF Design Patterns Book - Head First Design Patterns Design Patterns #3 Reid Holmes Lecture 16 - Thursday November 15 2011. GoF design patterns $ %!!!! $ "! # &
More informationDesign patterns Behavioral Pattern 2015
Behavioral Patterns Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects. Behavioral patterns describe not just patterns of objects or classes but also
More informationTecniche di Progettazione: Design Patterns
Tecniche di Progettazione: Design Patterns GoF: Mediator Memento Prototype 1 Design patterns, Laura Semini, Università di Pisa, Dipartimento di Informatica. Mediator 2 Design patterns, Laura Semini, Università
More informationCSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1
CSCI 6234 Object Oriented Design: Frameworks and Design Patterns George Blankenship Frameworks and Design George Blankenship 1 Background A class is a mechanisms for encapsulation, it embodies a certain
More informationTHOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS
THOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS LOGISTICS HW3 due today HW4 due in two weeks 2 IN CLASS EXERCISE What's a software design problem you've solved from an idea you learned from someone else?
More informationCSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Iterator Pattern George Blankenship
CSCI 253 Object Oriented Design: Iterator Pattern George Blankenship George Blankenship 1 Creational Patterns Singleton Abstract factory Factory Method Prototype Builder Overview Structural Patterns Composite
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 informationObject-oriented Software Design Patterns
Object-oriented Software Design Patterns Concepts and Examples Marcelo Vinícius Cysneiros Aragão marcelovca90@inatel.br Topics What are design patterns? Benefits of using design patterns Categories and
More informationDesign Patterns Design patterns advantages:
Design Patterns Designing object-oriented software is hard, and designing reusable object oriented software is even harder. You must find pertinent objects factor them into classes at the right granularity
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 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 informationDefine an object that encapsulates how a set of objects interact.
MEDIATOR Presented By: Mallampati Bhava Chaitanya Intent Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other
More informationDESIGN PATTERNS Course 4
DESIGN PATTERNS Course 4 COURSE 3 - CONTENT Creational patterns Singleton patterns Builder pattern Prototype pattern Factory method pattern Abstract factory pattern CONTENT Structural patterns Adapter
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 informationDesign patterns generic models
Design patterns generic models Jyothish Maniyath CDC Software India Pvt Ltd 6 th Floor, Canberra Block, UB City, #24 Vittal Mallya Road, Bangalore, India +91 94482 46718 jyosh@maniyath.com ABSTRACT This
More informationDesign Patterns IV Structural Design Patterns, 1
Structural Design Patterns, 1 COMP2110/2510 Software Design Software Design for SE September 17, 2008 Class Object Department of Computer Science The Australian National University 18.1 1 2 Class Object
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 informationINSTITUTE OF AERONAUTICAL ENGINEERING
INSTITUTE OF AERONAUTICAL ENGINEERING (Autonomous) Dundigal, Hyderabad -500 0 COMPUTER SCIENCE AND ENGINEERING TUTORIAL QUESTION BANK Course Name : DESIGN PATTERNS Course Code : A7050 Class : IV B. Tech
More informationDesign Patterns. Softwaretechnik. Matthias Keil. Albert-Ludwigs-Universität Freiburg
Design Patterns Softwaretechnik Matthias Keil Institute for Computer Science Faculty of Engineering University of Freiburg 6. Mai 2013 Design Patterns Gamma, Helm, Johnson, Vlissides: Design Patterns,
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 informationDesign Patterns and Frameworks Command
Design Patterns and Frameworks Command Oliver Haase Oliver Haase Emfra Command 1/13 Description Classification: Object-based behavioral pattern Purpose: Encapsulate a command as an object. Allows to dynamically
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 informationCISC 322 Software Architecture
CISC 322 Software Architecture Lecture 14: Design Patterns Emad Shihab Material drawn from [Gamma95, Coplien95] Slides adapted from Spiros Mancoridis and Ahmed E. Hassan Motivation Good designers know
More informationDesign Patterns. Software Engineering. Sergio Feo-Arenis slides by: Matthias Keil
Design Patterns Software Engineering Sergio Feo-Arenis slides by: Matthias Keil Institute for Computer Science Faculty of Engineering University of Freiburg 30.06.2014 Design Patterns Literature Gamma,
More informationA Reconnaissance on Design Patterns
A Reconnaissance on Design Patterns M.Chaithanya Varma Student of computer science engineering, Sree Vidhyanikethan Engineering college, Tirupati, India ABSTRACT: In past decade, design patterns have been
More informationLecture 21: Design Patterns III
Lecture 21: Design Patterns III Software System Design and Implementation ITCS/ITIS 6112/8112 001 Fall 2008 Dr. Jamie Payton Department of Computer Science University of North Carolina at Charlotte Nov.
More informationS. No TOPIC PPT Slides
S. No TOPIC PPT Slides Behavioral Patterns Part-I introduction UNIT-VI 1 2 3 4 5 6 7 Chain of Responsibility Command interpreter Iterator Reusable points in Behavioral Patterns (Intent, Motivation, Also
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 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 informationExam in TDDB84: Design Patterns,
Exam in TDDB84: Design Patterns, 2014-10-24 14-18 Information Observe the following, or risk subtraction of points: 1) Write only the answer to one task on one sheet. Use only the front side of the sheets
More informationDesign Patterns IV. Alexei Khorev. 1 Structural Patterns. Structural Patterns. 2 Adapter Design Patterns IV. Alexei Khorev. Structural Patterns
Structural Design Patterns, 1 1 COMP2110/2510 Software Design Software Design for SE September 17, 2008 2 3 Department of Computer Science The Australian National University 4 18.1 18.2 GoF Structural
More informationCommand. Comp-303 : Programming Techniques Lecture 22. Alexandre Denault Computer Science McGill University Winter 2004
Command Comp-303 : Programming Techniques Lecture 22 Alexandre Denault Computer Science McGill University Winter 2004 April 1, 2004 Lecture 22 Comp 303 : Command Page 1 Last lecture... Chain of Responsibility
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 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. SE3A04 Tutorial. Jason Jaskolka
SE3A04 Tutorial Jason Jaskolka Department of Computing and Software Faculty of Engineering McMaster University Hamilton, Ontario, Canada jaskolj@mcmaster.ca November 18/19, 2014 Jason Jaskolka 1 / 35 1
More informationObject-Oriented Design
Object-Oriented Design Lecture 14: Design Workflow Department of Computer Engineering Sharif University of Technology 1 UP iterations and workflow Workflows Requirements Analysis Phases Inception Elaboration
More informationBehavioral Design Patterns Used in Data Structures Implementation
Behavioral Design Patterns Used in Data Structures Implementation Niculescu Virginia Department of Computer Science Babeş-Bolyai University, Cluj-Napoca email address: vniculescu@cs.ubbcluj.ro November,
More informationAPPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS
APPLYING DESIGN PATTERNS TO SCA IMPLEMENTATIONS Adem Zumbul (TUBITAK-UEKAE, Kocaeli, Turkey, ademz@uekae.tubitak.gov.tr); Tuna Tugcu (Bogazici University, Istanbul, Turkey, tugcu@boun.edu.tr) ABSTRACT
More information