Template Method Pa.ern and Iterator Pa.ern
|
|
- Dale Weaver
- 5 years ago
- Views:
Transcription
1 Template Method Pa.ern and Iterator Pa.ern CSCI 3132 Summer
2 Template Method (Behavioral) Intent Define the skeleton of an algorithm in an opera;on, deferring some steps to subclasses Applicability To implement invariant aspects of an algorithm once and let subclasses define variant parts To localize common behavior in a class to increase code reuse To control subclass extensions 2
3 Example: StarBuzz Coffee Recipe Boil some water Brew coffee in boiling water Pour coffee in cup add sugar and milk Tea Recipe Boil some water Steep tea in boiling water Pour tea in cup Add lemon Suppose you are required to implement a system to maintain this 3
4 Problems with the Solu;on Code is duplicated across the classes code changes would have to be made in more than one place. Adding a new beverage would result in further duplica;on. Knowledge of the algorithm and implementa;on is distributed over classes. 4
5 More General Approach Both subclasses inherit a general algorithm. Some methods in the algorithm are concrete, i.e. methods that perform the same ac;ons for all subclasses. Other methods in the algorithm are abstract, i.e. methods that perform class- specific ac;ons. 5
6 Class Diagram for the New Approach 6
7 Abstrac;ng Prepare Recipe 7
8 Advantages of the New Approach A single class protects and controls the algorithm, namely, CaffeineBeverage. The superclass facilitates reuse of methods. Code changes will occur in only one place. Other beverages can be easily added. 8
9 This is the Template Method Pa.ern The preparerecipe() method implements the template pa.ern. This method serves as a template for an algorithm, namely that for making a caffeinated beverage. In the template each step is represented by a method. Some methods are implemented in the superclass. Other method must be implemented by the subclass and are declared abstract. The template pa.ern defines the steps of an algorithm and allows the subclasses to implement one or more of the steps. 9
10 Template Pa.ern Encapsulates an algorithm by crea;ng a template for it. Defines the skeleton of an algorithm as a set of steps. Some methods of the algorithm have to be implemented by the subclasses these are abstract methods in the super class. The subclasses can redefine certain steps of the algorithm without changing the algorithm s structure. Some steps of the algorithm are concrete methods defined in the super class. 10
11 Template Pa.ern Structure 11
12 Terminology Hook methods: placeholders for the behaviour to be implemented by subclasses Template methods: methods containing hook methods Hot spots: changeable behaviours of generic classes represented by hook methods Frozen spots: fixed behaviours of generic classes represented by template methods AbstractClass templatemethod() hookmethod1() hookmethod2() hookmethod1() hookmethod2() ConcreteClass hookmethod1() hookmethod2() 12
13 Using Hooks We want to minimize the number of abstract methods used. Thus, the steps of the algorithm should not be too granular. However, less granularity means less flexibility. Hooks are methods which can be overridden by subclasses, however this is op;onal. Example: Suppose the customer is given an op;on as to whether they would like condiments or not. 13
14 Why Hooks The number of abstract methods used must be minimized. Enables a subclass to implement an op;onal part of an algorithm. Enables a subclass to react to a step in the template method. Enables the subclass to make a decision for the abstract class. 14
15 Hollywood Principle The template pa.ern follows the hollywood principle. Principle: Don t call us, we will call you. Low- level components are ac;vated by high- level components. A low- level component never calls a high- level component. In the template pa.ern the abstract class is the high- level component and the concrete classes the low- level components. 15
16 Template Summary Design Principle: Don t call us we ll call you. Template pa.ern defines steps of an algorithm. Subclasses cannot change the algorithm. Facilitates code reuse. Similar to the strategy pa.ern, but different! 16
17 Design Principle If collec;ons have to manage themselves as well as itera;on of the collec;on this gives the class two responsibili;es instead of one. More than one responsibility means more than one area of change. Thus, each class should be restricted to a single responsibility. Single responsibility: A class should have only one reason to change. Find what varies and encapsulate it. 17
18 Iterator design pa.ern O]en you may have to move through a collec;on Tree (splay, AVL, binary, red- black, etc.), linked list, array, hash table, dic;onary, etc. If it s an array or vector, then this is easy But hard if it s a more complicated data structure Hash table, dic;onary, etc. The code doing the itera;on should not have to know the details of the data structure being used This pa.ern answers the ques;on: How do you provide a standard interface for moving through a collec;on of objects whose data structure is unknown? 18
19 Problems Suppose we are required to print every item on two menus (dinner menu and pancake menu) that stored in different structures. Two loops will be needed instead of one. If a third restaurant is included, three loops will be needed. Design principles that would be violated: Coding to implementa;on rather than interface The program implemen;ng the joint print_menu() needs to know the internal structure of the collec;on of each set of menu items. Duplica;on of code 19
20 Solu;on Encapsulate what varies, i.e. encapsulate the itera;on. An iterator is used for this purpose. The DinerMenu class and the PancakeMenu class need to implement a method called createiterator (). The Iterator is used to iterate through each collec;on without knowing its type (i.e. Array or ArrayList) 20
21 Original Itera;on Gebng the menu items: PancakeHouseMenu pancakehousemenu= new PancakeHouseMenu(); ArrayList breakfastitems = pancakehousemenu.getmenuitems(); DinerMenu dinermenu = new DinerMenu(); MenuItems[] lunchitems = dinermenu.getmenuitems(): Itera;ng through the breakfast items: for(int i=0; i < breakfastitems.size(); ++i) { MenuItem menuitem= (MenuItem) breakfastitems.get(i) } Itera;ng through the lunch items: for(int i=0; I < lunchitems.length; i++) { MenuItem menuitem = lunchitems[i] } 21
22 Using an Iterator Itera;ng through the breakfast items: Iterator iterator = breakfastmenu.createiterator(); while(iterator.hasnext()) { MenuItem menuitem = (MenuItem)iterator.next(); } Itera;ng through the lunch items: Iterator iterator = lunchmenu.createiterator(); while(iterator.hasnext()) { MenuItem menuitem = (MenuItem)iterator.next(); } 22
23 Class Diagram 23
24 Iterator Pa.ern Defini;on Provides a way to access elements of a collec;on object sequen;ally without exposing its underlying representa;on. The iterator object takes the responsibility of traversing a collec;on away from collec;on object. This simplifies the collec;on interface and implementa;on. Allows the traversal of the elements of a collec;on without exposing the underlying implementa;on. 24
25 Iterator Pa.ern The key par;cipants in this pa.ern are: The Iterator, which provides an (virtual) interface for moving through a collec;on of things The Aggregate, which defines the (virtual) interface for a collec;on that provides iterators The ConcreteIterator, which is the class that inherits/extends/ implements the Iterator The ConcreteAggregate, which is the class that inherits/extends/ implements the Aggregate This pa.ern is also known as cursor Iterator is a pa.ern that shows why we would use mul;ple inheritance 25
26 Iterator Pa.ern: Structure 26
27 Iterator Pa.ern: class Iterator We use an abstract C++ class to define the Iterator: template <class Item> class Iterator { public: virtual void First() = 0; virtual void Next() = 0; virtual bool IsDone() const = 0; virtual Item CurrentItem() const = 0; protected: Iterator(); } Any collec;on class that wants to define an iterator will define another (concrete iterator) class that inherits from this class 27
28 Iterator pa.ern: class AbstractAggregate We use an abstract C++ class to define the AbstractAggregate: template <class Item> class AbstractAggregate { public: } virtual Iterator<Item>* CreateIterator() const = 0; //... Any collec;on class that wants to provide iterators will inherit from this class 28
29 Iterator pa.ern: class List We use a sample C++ class to define a collec;on class (List): template <class Item> class List : public AbstractAggregate { public: List (long size = DEFAULT_LIST_CAPACITY); long Count() const; Item& Get (long index) const; //... } // and the method to provide the iterator... Obviously, this class could be a hash table, dic;onary, tree, etc. 29
30 Iterator pa.ern: class ListIterator We use an abstract C++ class to define the Iterator: template <class Item> class ListIterator : public Iterator<Item> { public: ListIterator (const List<Item>* alist); void First(); void Next(); bool IsDone() const; Item CurrentItem() const; private: const List<Item>* _list; long _current; } Any collec;on class that wants to define an iterator will define 30 another (concrete iterator) class that inherits from this class
31 Iterator pa.ern: class ListIterator cont d template <class Item> ListIterator<Item>::ListIterator ( const List<Item>* alist ) : _list(alist), _current(0) { } template <class Item> void ListIterator<Item>::First() { _current = 0; } template <class Item> void ListIterator<Item>::Next() { _current++; } 31
32 Iterator pa.ern: class ListIterator cont d template <class Item> void ListIterator<Item>::IsDone() const { return _current >= _list->count(); } template <class Item> void ListIterator<Item>::CurrentItem() const { if (IsDone()) throw IteratorOutOfBounds; return _list->get(_current); } 32
33 Using the Iterator void PrintEmpolyees (Iterator<Emplyee*>& i){ for( i.first();!i.isdone(); i.next()) i.currentitem() -> Print(); } List<Employee*>* employees; // ListIterator<Employee*> forward(employees); ReverseListIterator<Employee*> backward(employees); PrintEmployees(forward); PrintEmplyees(backward); 33
34 Iterator Pa.ern Consequences An iterator supports varia;ons in transversal of an aggregate The List class can provide one that iterates forward or backward Moving through a tree can be done in pre- order, in- order, or post- order Iterators support the aggregate interface As it doesn t have to define similar methods More than one transversal can be moving through an aggregate Mul;ple iterators can be working at any given ;me 34
35 Extra: 3D generic world in C++ STL DATA STRUCTURES ALGORITHMS ITERATORS 35
Tecniche di Progettazione: Design Patterns
Tecniche di Progettazione: Design Patterns GoF: Iterator 1 Design patterns, Laura Semini, Università di Pisa, Dipartimento di Informatica. The Iterator Pattern Intent Provide a way to access the elements
More informationTecniche di Progettazione: Design Patterns
Tecniche di Progettazione: Design Patterns GoF: Iterator 1 Design patterns, Laura Semini, Università di Pisa, Dipartimento di Informatica. Diner and Pancake House Merger Objectville diner and Objectville
More informationTemplate Method. Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 24 11/15/2007. University of Colorado, 2007
Template Method Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/6448 Lecture 24 11/15/2007 University of Colorado, 2007 1 Lecture Goals Cover Material from Chapter 8 of the Design Patterns
More informationDepth-First Search and Template Patterns
Depth-First Search and Template Patterns A B D E C 1 Outline Template Patterns and Search Depth-first search Algorithm Example Properties Analysis Applications of DFS Path finding Cycle finding CS 4407,
More informationTemplate Method, Iterator & Composite
Template Method, Iterator & Composite Kenneth M. Anderson University of Colorado, Boulder CSCI 4448/5448 Lecture 23 11/10/2008 University of Colorado, 2009 1 Lecture Goals Cover Material from Chapter 8
More informationTecniche di Progettazione: Design Patterns
Tecniche di Progettazione: Design Patterns GoF: Template method 1 Design patterns, Laura Semini, Università di Pisa, Dipartimento di Informatica. Hint The underlying is idea not so different from Factory
More informationDesign Patterns. Claus Jensen
Design Patterns Claus Jensen What is a Design Pattern? A design pattern Abstracts a recurring design structure Distils design experience Promotes reuse of design and code Gives an opportunity to see how
More informationMORE DESIGN PATTERNS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 24 11/10/2011
MORE DESIGN PATTERNS CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 24 11/10/2011 Kenneth M. Anderson, 2011 1 Goals of the Lecture Cover the material in Chapters 18 & 19 of our textbook Observer
More informationDesign Patterns: Composite, Memento, Template Method, Decorator, Chain of Responsibility, Interpreter
Design Patterns: Composite, Memento, Template Method, Decorator, Chain of Responsibility, Interpreter Composite Outline for Week 14 [Skrien 8.7] We need to allow users to group figures together to make
More informationDesign Patterns. State. Oliver Haase
Design Patterns State Oliver Haase 1 Description Object based behavioral pattern Purpose: Allow an object to alter its behavior when its internal state changes. The object will appear to change its class.
More informationDesign Patterns: Template Method, Strategy, State, Bridge
Design Patterns: Template Method, Strategy, State, Bridge [HFDP, Ch. 8] Say we have two classes whose code looks similar, but isn t identical. We can duplicate the code, but change it where changes are
More information09. ITERATOR AND COMPOSITE PATTERNS Well-Managed Collections. There are lots of ways to stuff objects into a collection.
BIM492 DESIGN PATTERNS 09. ITERATOR AND COMPOSITE PATTERNS Well-Managed Collections There are lots of ways to stuff objects into a collection. Breaking News: Objectville Diner and Objectville Pancake House
More informationDesign Patterns. Produced by. Eamonn de Leastar Department of Computing, Maths & Physics Waterford Institute of Technology
Design Patterns 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 Template Method Design
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 informationDesign Pa*erns. + Anima/on Undo/Redo Graphics and Hints
Design Pa*erns + Anima/on Undo/Redo Graphics and Hints Design Pa*erns Design: the planning that lays the basis for the making of every object or system Pa*ern: a type of theme of recurring events or objects
More informationRDD and Strategy Pa.ern
RDD and Strategy Pa.ern CSCI 3132 Summer 2011 1 OO So1ware Design The tradi7onal view of objects is that they are data with methods. Smart Data. But, it is be.er to think of them as en##es that have responsibili#es.
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 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 informationCSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Template Method Pattern. George Blankenship
CSCI 253 Object Oriented Design: George Blankenship George Blankenship 1 Creational Patterns Singleton Abstract factory Factory Method Prototype Builder Overview Structural Patterns Composite Façade Proxy
More informationTackling Design Patterns Chapter 3: Template Method design pattern and Public Inheritance. 3.1 Introduction... 2
Department of Computer Science Tackling Design Patterns Chapter 3: Template Method design pattern and Public Inheritance Copyright c 2016 by Linda Marshall and Vreda Pieterse. All rights reserved. Contents
More informationInterfaces and itera-on. CSCI 136: Fundamentals of Computer Science II Keith Vertanen
Interfaces and itera-on CSCI 136: Fundamentals of Computer Science II Keith Vertanen Overview A shape object hierarchy Classes that extend Versus classes that implements Java interfaces How Java handles
More informationStructure Patters: Bridge and Flyweight. CSCI 3132 Summer
Structure Patters: Bridge and Flyweight CSCI 3132 Summer 2011 1 Introducing the Bridge Pa1ern Intent To decouple an abstrac7on from its implementa7on so that the two can vary independently. What does it
More informationThe Template Method Pattern
The Template Method Pattern Intent Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. Template Method lets subclasses redefine certain steps of an algorithm without
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 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 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 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 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 informationObject Oriented Design (OOD): The Concept
Object Oriented Design (OOD): The Concept Objec,ves To explain how a so8ware design may be represented as a set of interac;ng objects that manage their own state and opera;ons 1 Topics covered Object Oriented
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 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 informationJosh Bloch Charlie Garrod Darya Melicher
Principles of So3ware Construc9on: Objects, Design, and Concurrency Part 2: Class-level design Design paderns for reuse, part 2 Josh Bloch Charlie Garrod Darya Melicher 1 Administrivia Reading due today:
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 informationChapter 5 Object-Oriented Programming
Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares
More informationBEHAVIORAL DESIGN PATTERNS
BEHAVIORAL DESIGN PATTERNS BEHAVIORAL DESIGN PATTERNS Identifies common communication patterns between objects that realize these patterns Describes the objects and classes interact and divide responsibilities
More informationDesign Patterns (Composite, Iterator)
CS 246: Software Abstraction and Specification Lecture 17 Design Patterns (Composite, Iterator) Reading: Head First Design Patterns U Waterloo CS246se (Spring 2011) p.1/30 Today's Agenda Design patterns:
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 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 informationCOSC 121: Computer Programming II. Dr. Bowen Hui University of Bri?sh Columbia Okanagan
COSC 121: Computer Programming II Dr. Bowen Hui University of Bri?sh Columbia Okanagan 1 A1 Posted over the weekend Two ques?ons (s?ll long ques?ons) Review of main concepts from COSC 111 Prac?ce coding
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 informationPart 1: Excep-ons, part 2 Part 2: Iterator. Lecture 11 COMP 401, Spring /3/2015
Part 1: Excep-ons, part 2 Part 2: Iterator Lecture 11 COMP 401, Spring 2015 3/3/2015 The finally block Some-me we need some code to run no maker what happens. OMen this is the case in order to free up
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 (Iterator)
CS 247: Software Engineering Principles Design Patterns (Iterator) Reading: Freeman, Robson, Bates, Sierra, Head First Design Patterns, O'Reilly Media, Inc. 2004 Ch 9: Composite and Iterator Patterns Electronic
More informationJava. Package, Interface & Excep2on
Java Package, Interface & Excep2on Package 2 Package Java package provides a mechanism for par55oning the class name space into more manageable chunks Both naming and visibility control mechanism Define
More informationDesign Patterns. "Gang of Four"* Design Patterns. "Gang of Four" Design Patterns. Design Pattern. CS 247: Software Engineering Principles
CS 247: Software Engineering Principles Design Patterns Reading: Freeman, Robson, Bates, Sierra, Head First Design Patterns, O'Reilly Media, Inc. 2004 Ch Strategy Pattern Ch 7 Adapter and Facade patterns
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 informationCharlie Garrod Michael Hilton
Principles of So3ware Construc9on: Objects, Design, and Concurrency Part 4: Design for large-scale reuse Libraries and frameworks Charlie Garrod Michael Hilton School of Computer Science 1 Administrivia
More informationCS 247: Software Engineering Principles. Design Patterns
CS 247: Software Engineering Principles Design Patterns Reading: Freeman, Robson, Bates, Sierra, Head First Design Patterns, O'Reilly Media, Inc. 2004 Ch 1 Strategy Pattern Ch 7 Adapter and Facade patterns
More informationDesign Pattern and Software Architecture: IV. Design Pattern
Design Pattern and Software Architecture: IV. Design Pattern AG Softwaretechnik Raum E 3.165 Tele.. 60-3321 hg@upb.de IV. Design Pattern IV.1 Introduction IV.2 Example: WYSIWYG Editor Lexi IV.3 Creational
More informationIterator pattern. Acknowledgement: Eric Braude
Iterator pattern Acknowledgement: Eric Braude Let s try this Data structures: l Array l Binary Tree l Vector l Linked list l Hash table Algorithm: l Sort l Find l Merge How many permutations to develop/maintain?
More informationDesign Pa*erns. Philippe Collet. Master 1 IFI Interna3onal h8p://dep3nfo.unice.fr/twiki/bin/view/minfo/soeeng1213. P.
Design Pa*erns Philippe Collet Master 1 IFI Interna3onal 2012-2013 h8p://dep3nfo.unice.fr/twiki/bin/view/minfo/soeeng1213 P. Collet 1 Agenda Introduc3on First example Principles and classifica3on Presenta3on
More informationL18.1 Introduction... 2
Department of Computer Science COS121 Lecture Notes: L18 Iterator Design Pattern 8 September 2014 Copyright c 2014 by Linda Marshall and Vreda Pieterse. All rights reserved. Contents L18.1 Introduction.................................
More informationSoftware Paradigms (Lesson 3) Object-Oriented Paradigm (2)
Software Paradigms (Lesson 3) Object-Oriented Paradigm (2) Table of Contents 1 Reusing Classes... 2 1.1 Composition... 2 1.2 Inheritance... 4 1.2.1 Extending Classes... 5 1.2.2 Method Overriding... 7 1.2.3
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 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 informationAgenda. Excep,ons Object oriented Python Library demo: xml rpc
Agenda Excep,ons Object oriented Python Library demo: xml rpc Resources h?p://docs.python.org/tutorial/errors.html h?p://docs.python.org/tutorial/classes.html h?p://docs.python.org/library/xmlrpclib.html
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 informationCharlie Garrod Bogdan Vasilescu
Principles of So3ware Construc9on: Objects, Design, and Concurrency Part 2: Designing (sub-) systems Design for large-scale reuse: Libraries and frameworks Charlie Garrod Bogdan Vasilescu School of Computer
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 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 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 informationUNIT II A. ENTITY RELATIONSHIP MODEL
UNIT II A. ENTITY RELATIONSHIP MODEL Agenda En0ty & En0ty Sets A6ributes Rela0onship & Rela0onship Sets Constraints Mapping Cardinali0es, Par0cipa0on Constraints, Keys E-R Diagrams & Design of Database
More informationCOURSE 2 DESIGN PATTERNS
COURSE 2 DESIGN PATTERNS CONTENT Fundamental principles of OOP Encapsulation Inheritance Abstractisation Polymorphism [Exception Handling] Fundamental Patterns Inheritance Delegation Interface Abstract
More informationGeneric Programming Redesign of Patterns
Generic Programming Redesign of Patterns Thierry Géraud and Alexandre Duret-Lutz Thierry.Geraud@lrde.epita.fr Alexandre.Duret-Lutz@lrde.epita.fr EPITA Research and Development Laboratory 14-16 rue Voltaire,
More informationWhy a Design Pattern. History of Design Pattern. Properties
Introduction to Design Patterns Nasreddine Aoumeur Why a Design Pattern Reusability: one of the basis for an efficient and actual SE discipline Helping new designers to have a more flexible and reusable
More information» Access elements of a container sequentially without exposing the underlying representation
Iterator Pattern Behavioural Intent» Access elements of a container sequentially without exposing the underlying representation Iterator-1 Motivation Be able to process all the elements in a container
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 informationEECS 4314 Advanced Software Engineering. Topic 04: Design Pattern Review Zhen Ming (Jack) Jiang
EECS 4314 Advanced Software Engineering Topic 04: Design Pattern Review Zhen Ming (Jack) Jiang Acknowledgement Some slides are adapted from Ahmed E. Hassan, Jonathan Ostroff, Spiros Mancoridis and Emad
More informationWhat s Conformance? Conformance. Conformance and Class Invariants Question: Conformance and Overriding
Conformance Conformance and Class Invariants Same or Better Principle Access Conformance Contract Conformance Signature Conformance Co-, Contra- and No-Variance Overloading and Overriding Inheritance as
More informationInheritance. Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L
Inheritance Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 9.4 1 Inheritance Inheritance allows a software developer to derive
More informationINHERITED BEHAVIOUR PATTERN
INHERITED BEHAVIOUR PATTERN Class Behavioral Intent Extends the behaviour of a method in subclasses by reusing the inherited method and adding to it. This pattern is supported by some object-oriented languages
More informationSingleton Pattern Creational
Singleton Pattern Creational Intent» Ensure a class has only one instance» Provide a global point of access Motivation Some classes must only have one instance file system, window manager Applicability»
More informationChapter 10 INHERITANCE 11/7/16 1
Chapter 10 INHERITANCE 11/7/16 1 Chapter Goals To learn about inheritance To implement subclasses that inherit and override superclass methods To understand the concept of polymorphism In this chapter,
More informationOutline. Purpose. Useful Definitions. Pattern Overview
Design Patterns Outline Purpose Useful Definitions Pattern Overview Purpose To provide programmers with already documented solutions to common problems. Gives the programmers a common language. COMPOSITION?
More informationProgramming II (CS300)
1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract Classes
More informationTable of Contents (summary) Table of Contents (the real thing)
Table of Contents (summary) Intro xxv 1 Welcome to Design Patterns: an introduction 1 2 Keeping your Objects in the know: the Observer Pattern 37 3 Decorating Objects: the Decorator Pattern 79 4 Baking
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 informationA formal design process, part 2
Principles of So3ware Construc9on: Objects, Design, and Concurrency Designing (sub-) systems A formal design process, part 2 Josh Bloch Charlie Garrod School of Computer Science 1 Administrivia Midterm
More informationData Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1
Design Principles Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques 2-1 Data Structures Data Structure - A systematic way of organizing and accessing
More informationFINAL TERM EXAMINATION SPRING 2010 CS304- OBJECT ORIENTED PROGRAMMING
FINAL TERM EXAMINATION SPRING 2010 CS304- OBJECT ORIENTED PROGRAMMING Question No: 1 ( Marks: 1 ) - Please choose one Classes like TwoDimensionalShape and ThreeDimensionalShape would normally be concrete,
More informationJava Programming Unit 8. Selected Java Collec5ons. Generics.
Java Programming Unit 8 Selected Java Collec5ons. Generics. Java Collec5ons Framework Classes and interfaces from packages java.util and java.util.concurrent are called Java Collec5ons Framework. java.u5l:
More informationInheritance. Lecture 11 COP 3252 Summer May 25, 2017
Inheritance Lecture 11 COP 3252 Summer 2017 May 25, 2017 Subclasses and Superclasses Inheritance is a technique that allows one class to be derived from another. A derived class inherits all of the data
More informationOO Design Principles
OO Design Principles Software Architecture VO (706.706) Roman Kern Institute for Interactive Systems and Data Science, TU Graz 2018-10-10 Roman Kern (ISDS, TU Graz) OO Design Principles 2018-10-10 1 /
More informationIntroduction to Design Patterns
Dr. Michael Eichberg Software Technology Group Department of Computer Science Technische Universität Darmstadt Introduction to Software Engineering Introduction to Design Patterns Patterns 2 PATTERNS A
More informationCSCI-142 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community
CSCI-12 Exam 1 Review September 25, 2016 Presented by the RIT Computer Science Community http://csc.cs.rit.edu 1. Provide a detailed explanation of what the following code does: 1 public boolean checkstring
More informationObserver Templates. CS 5010 Program Design Paradigms Lesson 1.4
Observer Templates CS 5010 Program Design Paradigms Lesson 1.4 Mitchell Wand, 2012-2014 This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License. 1 Learning Objectives
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 informationLesson 13 - Vectors Dynamic Data Storage
Lesson 13 - Vectors Dynamic Data Storage Summary In this lesson we introduce the Standard Template Library by demonstrating the use of Vectors to provide dynamic storage of data elements. New Concepts
More information1B1b Inheritance. Inheritance. Agenda. Subclass and Superclass. Superclass. Generalisation & Specialisation. Shapes and Squares. 1B1b Lecture Slides
1B1b Inheritance Agenda Introduction to inheritance. How Java supports inheritance. Inheritance is a key feature of object-oriented oriented programming. 1 2 Inheritance Models the kind-of or specialisation-of
More informationObject-Oriented Concepts and Design Principles
Object-Oriented Concepts and Design Principles Signature Specifying an object operation or method involves declaring its name, the objects it takes as parameters and its return value. Known as an operation
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 informationInheritance and Encapsulation. Amit Gupta
Inheritance and Encapsulation Amit Gupta Project 1 How did it go? What did you like about it? What did you not like? What can we do to help? Suggestions Ask questions if you don t understand a concept
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationObject-Oriented Oriented Programming
Object-Oriented Oriented Programming Visitor Pattern Observer Pattern CSIE Department, NTUT Woei-Kae Chen Visitor Pattern Visitor Pattern Behavioral pattern Visitor: Intent Represent an operation to be
More information03. DECORATOR PATTERN. Design Eye for the Inheritance Guy
BIM492 DESIGN PATTERNS 03. DECORATOR PATTERN Design Eye for the Inheritance Guy Welcome to Starbuzz Coffee Starbuzz Coffee is the fastest growing coffee shop around --> if you see one, look across the
More informationBack to ObjectLand. Contents at: Chapter 5. Questions of Interest. encapsulation. polymorphism. inheritance overriding inheritance super
korienekch05.qxd 11/12/01 4:06 PM Page 105 5 Back to ObjectLand Contents at: Chapter 5 #( encapsulation polymorphism inheritance overriding inheritance super learning the class hierarchy finding classes
More informationWriting your own Java I/O Decorator p. 102 Tools for your Design Toolbox p. 105 Exercise Solutions p. 106 The Factory Pattern Baking with OO
Intro to Design Patterns Welcome to Design Patterns: Someone has already solved your problems The SimUDuck app p. 2 Joe thinks about inheritance... p. 5 How about an interface? p. 6 The one constant in
More informationCS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS. MC
CS304- Object Oriented Programming LATEST SOLVED MCQS FROM FINALTERM PAPERS JAN 28,2011 MC100401285 Moaaz.pk@gmail.com Mc100401285@gmail.com PSMD01 FINALTERM EXAMINATION 14 Feb, 2011 CS304- Object Oriented
More informationInterface. Design Patterns 2. Why use Interface? Design Principles. Adapter 11/7/2011. Michael Li
G5APR Applications Programming Design Patterns Michael Li email: jwl@cs.nott.ac.uk http://www.cs.nott.ac.uk/~jwl/g5apr Interface An Interface is a collection of abstract methods that an object implements
More informationSingleton Pattern Creational. » Ensure a class has only one instance» Provide a global point of access
Singleton Pattern Creational Intent» Ensure a class has only one instance» Provide a global point of access Motivation Some classes must only have one instance file system, window manager Applicability»
More information