Design Pattern and Software Architecture: IV. Design Pattern

Similar documents
SDC Design patterns GoF

Composite Pattern. IV.4 Structural Pattern

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

INSTITUTE OF AERONAUTICAL ENGINEERING

Design Patterns. Manuel Mastrofini. Systems Engineering and Web Services. University of Rome Tor Vergata June 2011

Introduction to Software Engineering: Object Design I Reuse & Patterns

Object-Oriented Design

UNIT I Introduction to Design Patterns

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

Keywords: Abstract Factory, Singleton, Factory Method, Prototype, Builder, Composite, Flyweight, Decorator.

UNIT I Introduction to Design Patterns

Design Patterns. An introduction

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

CSCI Object Oriented Design: Frameworks and Design Patterns George Blankenship. Frameworks and Design George Blankenship 1

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

The Strategy Pattern Design Principle: Design Principle: Design Principle:

What is a Pattern? Lecture 40: Design Patterns. Elements of Design Patterns. What are design patterns?

DESIGN PATTERN - INTERVIEW QUESTIONS

An Introduction to Patterns

Design Pattern- Creational pattern 2015

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Design Patterns. Observations. Electrical Engineering Patterns. Mechanical Engineering Patterns

Object-Oriented Oriented Programming

Creational Patterns. Factory Method (FM) Abstract Factory (AF) Singleton (SI) Prototype (PR) Builder (BU)

Object-oriented Software Design Patterns

Trusted Components. Reuse, Contracts and Patterns. Prof. Dr. Bertrand Meyer Dr. Karine Arnout

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

OODP Session 4. Web Page: Visiting Hours: Tuesday 17:00 to 19:00

2.1 Design Patterns and Architecture (continued)

2.1 Design Patterns and Architecture (continued)

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

Software Design COSC 4353/6353 D R. R A J S I N G H

R07. IV B.Tech. II Semester Supplementary Examinations, July, 2011

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Design Patterns. SE3A04 Tutorial. Jason Jaskolka

Using Design Patterns in Java Application Development

In this Lecture you will Learn: Design Patterns. Patterns vs. Frameworks. Patterns vs. Frameworks

Ingegneria del Software Corso di Laurea in Informatica per il Management. Design Patterns part 1

Design Patterns Reid Holmes

Creational Design Patterns

Software Engineering Prof. Rushikesh K.Joshi IIT Bombay Lecture-15 Design Patterns

The GoF Design Patterns Reference

Design Patterns. Gunnar Gotshalks A4-1

Software Design COSC 4353/6353 D R. R A J S I N G H

Object Oriented Methods with UML. Introduction to Design Patterns- Lecture 8

Socket attaches to a Ratchet. 2) Bridge Decouple an abstraction from its implementation so that the two can vary independently.

WS01/02 - Design Pattern and Software Architecture

Topics in Object-Oriented Design Patterns

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

administrivia today UML start design patterns Tuesday, September 28, 2010

Laboratorio di Progettazione di Sistemi Software Design Pattern Creazionali. Valentina Presutti (A-L) Riccardo Solmi (M-Z)

Slide 1. Design Patterns. Prof. Mirco Tribastone, Ph.D

What is Design Patterns?

Pro Objective-C Design Patterns for ios

CHAPTER 6: CREATIONAL DESIGN PATTERNS

Design patterns. Jef De Smedt Beta VZW

Overview CS Kinds of Patterns. Design Pattern. Factory Pattern Rationale. Kinds of Factory Patterns

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

Summary of the course lectures

Department of Information Technology

A few important patterns and their connections

Plan. A few important patterns and their connections. Singleton. Singleton: class diagram. Singleton Factory method Facade

design patterns FOR B.tech (jntu - hyderabad & kakinada) (IV/I - CSE AND IV/II - IT) CONTENTS 1.1 INTRODUCTION TO DESIGN PATTERNS TTERNS... TTERN?...

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

Information systems modelling UML and service description languages

DESIGN PATTERNS FOR MERE MORTALS

The Design Patterns Matrix From Analysis to Implementation

Design Patterns: Structural and Behavioural

4.1 Introduction Programming preliminaries Constructors Destructors An example... 3

Design Patterns. Dr. Rania Khairy. Software Engineering and Development Tool

SYLLABUS CHAPTER - 1 [SOFTWARE REUSE SUCCESS FACTORS] Reuse Driven Software Engineering is a Business

Modellistica Medica. Maria Grazia Pia, INFN Genova. Scuola di Specializzazione in Fisica Sanitaria Genova Anno Accademico

Design Patterns. Comp2110 Software Design. Department of Computer Science Australian National University. Second Semester

An Introduction to Patterns

CSCI 253. Overview. The Elements of a Design Pattern. George Blankenship 1. Object Oriented Design: Template Method Pattern. George Blankenship

Tuesday, October 4. Announcements

Design of Software Systems (Ontwerp van SoftwareSystemen) Design Patterns Reference. Roel Wuyts

Object Oriented Paradigm

SOLID DESIGN PATTERNS FOR MERE MORTALS

Exam in TDDB84: Design Patterns,

Design Patterns. (and anti-patterns)

Design Patterns. CSE870: Advanced Software Engineering (Design Patterns): Cheng

Brief Note on Design Pattern

LECTURE NOTES ON DESIGN PATTERNS MCA III YEAR, V SEMESTER (JNTUA-R09)

Design Patterns! Acknowledgements!

An Introduction to Object Orientation

Design Pa*erns. + Anima/on Undo/Redo Graphics and Hints

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

Object-Oriented Design

C++ for System Developers with Design Pattern

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Object Oriented Programming in Java. Jaanus Pöial, PhD Tallinn, Estonia

Design Patterns and Frameworks Command

Object-Oriented Design

CS 520/620 Advanced Software Engineering Fall September 27, 2016

Design Patterns. Hausi A. Müller University of Victoria. Software Architecture Course Spring 2000

Factory Method Pattern Creational. » Define an interface for creating an object but lets subclasses decide the specific class to instantiate

Creational. Structural

Transcription:

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 Pattern Singleton, Factory Method, Abstract Factory, Prototype IV.5 Structural Pattern Composite, Decorator, Bridge, Adapter IV.4 Behavioural Pattern Observer, Iterator, Strategy, Hook, Template Method, Visitor, Command, Memento IV.6 Discussion & Summary IV.7 Bibliography IV-2 1

IV.1 Introduction [Gamma+1994] Design Pattern: Ensure internal software qualities such as changeability at design level (not implementation!) Classification: Creational Patterns Structural Patterns Behavioural Patterns IV-3 IV.2 Example Design of a WYSIWYG Editor Lexi [Gamma+1994] Design Aspects: 1. Document structure 2. Text formatting, search for regular expressions, line breaking, spell checking 3. Global state system root, selection, zooming,... 4. User Interface 5. Different Look-And-Feels 6. Different Window systems 7. Undo/Redo, Macros,... IV-4 2

Coarse Grain Design Software Architecture IV-5 Internal Representation? IV-6 3

Tree Structure of What? IV-7 Concept of A Glyph Use basic OO: Use subtyping (not inheritance) to handle each specific glyph in a uniform manner Use shared aggregation or composition to describe composition structure IV-8 4

Text Formatting, Searching, Line Breaking, Spell Checking, <<creates>> <<creates>> <<creates>> <<creates>> <<creates>> IV-9 Manage Aspect using different Tools for Line Breaking, IV-10 5

Manage GUI Elements? IV-11 Support Multiple Window Systems IV-12 6

Support Undo/Redo IV-13 IV.3 Creational Pattern Motivation: abstract from instantiation process Make system independent of object creation [Gamma+1994] Basic Themes: Encapsulate knowledge about concrete classes Hide how objects are created and composed Details: What class? Who creates? How? When? Problems: Class creation spread over the code (no single point of change) Patterns: Singleton Factory Method Abstract Factory Prototype IV-14 7

Design Pattern Singleton Lexi system root: Exactly one root object Reachable from everywhere Support for dynamic subtyping [Gamma+1994] IV-15 Factory Method Pattern [Gamma+1994] Intent: Dynamic choice of the underlying class when creating the object Problem: Direct object creation via x = new C () creates exactly one object of fixed type C (no flexible choice supported) Solution: Encapsulate object creation in method Redefine method in subclasses Distinguish cases using parameters, options, environment Related Patterns: Often realized using the Prototype Pattern; see also Abstract Factory Pattern IV-16 8

Example: Document Creation IV-17 Abstract Factory Pattern Intent: Groups factory methods and structures creation of related objects Problem: How to manage the creation of families of related or dependent objects [Gamma+1994] Solution: Encapsulate their object creation within one class Redefine in subclasses as required Related Patterns: Often realized using the Factory Methods Pattern Often a concrete Factory is also a Singleton IV-18 9

Example: GUI Factory Abstract Factory with Factory Methods ensures type secure programs IV-19 Prototype Pattern [Gamma+1994] Intent: Reduce complex initialisation and constructor processing and instead clone an exist instance Problem: Initialisation of complex objects is often time consuming and required behaviour is not related to a new class but rather the composition of given classes (Java Swing) Related Patterns: An Abstract Factory might use a set of prototype to clone instead of create the required instances Design with the Composite and Decorator Pattern can often benefit from Prototype as well IV-20 10

Prototype Pattern Intent: Reduce complex initialisation and constructor processing and instead clone an exist instance Example: Extend Lexi with a Tool-Palette for a sheet of music IV-21 Example: Prototype & Cloning IV-22 11

" Example: Creational Patterns More flexible (GUI Factory does not know all widget types at compile-time) Abstract Factory with Prototypes required run-time type checks Often mixed forms IV-23 Dynamic Cast Pattern Problem: Type casts vs. secure static types that ensure correct usage of operation class etc. Language Solution: run-time test for casts (Exceptions) Limitation: Attempt to cast non-glyph to Composite is not detected at compile-time (only runtime error) Solution: Declare all valid casts in Glyph using to_composite Trade-off:! Superclass requires cast-op for all subclasses Somtimes multi level casts required IV-24 12