CISC 322 Software Architecture

Similar documents
EECS 4314 Advanced Software Engineering. Topic 04: Design Pattern Review Zhen Ming (Jack) Jiang

Topics in Object-Oriented Design Patterns

Object-Oriented Oriented Programming

COSC 3351 Software Design. Design Patterns Structural Patterns (I)

Design Patterns. Definition of a Design Pattern

Design Patterns IV. Alexei Khorev. 1 Structural Patterns. Structural Patterns. 2 Adapter Design Patterns IV. Alexei Khorev. Structural Patterns

Design Patterns IV Structural Design Patterns, 1

ADAPTER. Topics. Presented By: Mallampati Bhava Chaitanya

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

Introduction to Software Engineering (2+1 SWS) Winter Term 2009 / 2010 Dr. Michael Eichberg Vertretungsprofessur Software Engineering Department of

Software Eningeering. Lecture 9 Design Patterns 2

Design Patterns Lecture 2

Object Design II: Design Patterns

Facade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004

Introduction and History

Object-Oriented Oriented Programming Adapter Pattern. CSIE Department, NTUT Woei-Kae Chen

The Composite Design Pattern

Design Pattern: Composite

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

Design Patterns V Structural Design Patterns, 2

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

Object-Oriented Oriented Programming Adapter Pattern

Design Patterns! Acknowledgements!

Last Lecture. Lecture 17: Design Patterns (part 2) Kenneth M. Anderson Object-Oriented Analysis and Design CSCI 4448/ Spring Semester, 2005

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

Design Patterns Reid Holmes

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

Design Patterns in C++

CSE870: Advanced Software Engineering (Cheng) 1

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

Design Patterns. Gunnar Gotshalks A4-1

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

Adapter & Facade. CS356 Object-Oriented Design and Programming November 19, 2014

THOMAS LATOZA SWE 621 FALL 2018 DESIGN PATTERNS

EMBEDDED SYSTEMS PROGRAMMING Design Patterns

A Reconnaissance on Design Patterns

Design Patterns #3. Reid Holmes. Material and some slide content from: - GoF Design Patterns Book - Head First Design Patterns

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

6.3 Patterns. Definition: Design Patterns

EMBEDDED SYSTEMS PROGRAMMING Design Patterns

SDC Design patterns GoF

Design Patterns in Python (Part 2)

Software Engineering - I An Introduction to Software Construction Techniques for Industrial Strength Software

An Introduction to Patterns

Lecture 20: Design Patterns II

Why Design Patterns? OO Design Patterns. Design Patterns, Elements of Reusable Object-Oriented Software by Gamma, Helm, Johnson, & Vlissides

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

Material and some slide content from: - GoF Design Patterns Book. Design Patterns #1. Reid Holmes. Lecture 11 - Tuesday October

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

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

2.1 Design Patterns and Architecture (continued)

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

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

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

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

Lecture 13: Design Patterns

2.1 Design Patterns and Architecture (continued)

Pattern Resources. Lecture 25: Design Patterns. What are Patterns? Design Patterns. Pattern Languages of Programming. The Portland Pattern Repository

Composite Pattern. IV.4 Structural Pattern

Design Patterns. GoF design patterns catalog

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

Tecniche di Progettazione: Design Patterns

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

Design Pattern Detection

Goals of Lecture. Lecture 27: OO Design Patterns. Pattern Resources. Design Patterns. Cover OO Design Patterns. Pattern Languages of Programming

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

Software Engineering I (02161)

Adapter Pattern Structural

Object-Oriented Design

CS 2340 Objects and Design

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

Last Lecture. Lecture 26: Design Patterns (part 2) State. Goals of Lecture. Design Patterns

SOFTWARE PATTERNS. Joseph Bonello

Review of last class. 1.Class inheritance versus interface inheritance 2.Inheritance versus composition. Dr. Xiaolin Hu

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

Design Pattern Detection

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

DESIGN PATTERNS Course 4

Reuse at Design Level: Design Patterns

Design Patterns. An introduction

Design Patterns Reid Holmes


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

Details of Class Definition

Summary of the course lectures

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

INSTITUTE OF AERONAUTICAL ENGINEERING

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

From Patterns to Frameworks to Programs

Adapter pattern. Acknowledgement: Freeman & Freeman

COSC 3351 Software Design. Design Patterns Structural Patterns (II) Edgar Gabriel. Spring Decorator

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

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

COURSE 2 DESIGN PATTERNS

Design patterns. Valentina Presutti courtesy of Paolo Ciancarini

Behavioral patterns. Command Iterator Observer Strategy Template method

EINDHOVEN UNIVERSITY OF TECHNOLOGY

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

Brief Note on Design Pattern

Design Patterns. Decorator. Oliver Haase

Transcription:

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 not to solve every problem from first principles. They reuse solutions. Practitioners do not do a good job of recording experience in software design for others to use.

What is a Design Pattern A Design Pattern systematically names, explains, and evaluates an important and recurring design. descriptions of communicating objects and classes that are customized to solve a general problem in a particular context

Classifying Design Patterns Structural: concern the process of assembling objects and classes Behavioral: concern the interaction between classes or objects Creational: concern the process of object creation

Design Patterns Covered Structural Adapter Façade Composite Behavioral Iterator Template Observer Master-Slave Creational Abstract Factory

For Each Pattern. Motivation the problem we want to solve using the design pattern Intent the intended solution the design pattern proposes Structure How the design pattern is implemented Participants the components of the design pattern

Terminology Objects package both data and the procedures that operate on that data. Procedures are typically called methods or operations. An object performs an operation when it receives a request (or message) from a client.

Terminology An object s implementation is defined by its class. The class specifies Object s internal data and representation Operations that object can perform An abstract class is one whose main purpose is to define a common interface for its subclass

Terminology The set of signatures defined by an object s operations or methods is called the interface

Adapter Pattern - Intent Convert the interface of a class into another interface clients expect. Adapter lets classes work together that otherwise couldn t because of incompatible interfaces

Adapter Pattern - Motivation When we want to reuse classes in an application that expects classes with a different interface, we do not want (and often cannot) to change the reusable classes to suit our application

Lets users draw and arrange graphical elements Adapter Interface for graphical object OTS UI toolkit. Provides sophisticated class for displaying and editing text Subclass of shape defined by editor for lines Define TextShape to adapt TextView interface to Shape s Can change TextView class so it conforms to Shape interface would need source code of TextView. Too much work! BoundingBox requests are converted to GetExtent requests Allows objects to be dragged interactively

Adapter Pattern Structure Collaborates with objects conforming to the target interface Client Defines the applicationspecific interface that clients use Target Request() Defines an existing interface that needs adapting Adaptee SpecificRequest() Adapts the interface of the adaptee to the target interface Adapter Request() adaptee SpecificRequest()

Façade Pattern Intent 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.

Façade Pattern Motivation Structuring a system into subsystems helps reduce complexity. A common design goal is to minimize the communication and dependencies between subsystems. Use a facade object to provide a single, simplified interface to the more general facilities of a subsystem.

Façade Example Programming Environment Programming environment that provides access to its compiler Contains many classes (e.g. scanner, parser) Most clients don t care about details like parsing and code generation just compile my code! The low-level interfaces just complicate their task Compiler Compile() Scanner Token CodeGenerator Parser ProgNodeBuilder RISCCG ProgNode StackMachineCG Statement Node Expression Node Compiler Subsystem Classes Variable Node Software Design (OOD Patterns)

Façade Example Programming Environment Higher-level interface (i.e., Compiler class) shields clients from low level classes Compiler class defines a unified interface to the compiler s functionality Compiler class acts as a Façade. It offers clients a simple interface to the compiler subsystem Compiler Compile() Scanner Token CodeGenerator Parser ProgNodeBuilder RISCCG ProgNode StackMachineCG Statement Node Expression Node Compiler Subsystem Classes Variable Node Software Design (OOD Patterns)

Façade Pattern Structure Client Classes Facade Subsystem Classes Software Design (OOD Patterns)

Participants of Façade Pattern Façade (compiler) Knows which subsystem classes are responsible for a request Delegates client requests to appropriate subsystem objects Subsystem classes (Scanner, Parser,etc..) Implements subsystem functionality Handles work assigned by the façade object

Façade Pattern Applicability Use a façade when To provide a simple interface to a complex subsystem To decouple clients and implementation classes To define an entry point to a layered subsystem

Façade Pattern Collaborations Clients communicate with the subsystem by sending requests to façade, which then forwards requests to the appropriate subsystems Clients that use the façade don t have access to its subsystem objects directly. However, clients can access subsystem classes if they need to

Composite Pattern Intent Lets clients treat individual objects and compositions of objects uniformly

Composite Pattern Motivation If the composite pattern is not used, client code must treat primitive and container classes differently, making the application more complex than necessary

Composite Pattern Example Graphic applications allow users to build complex diagrams out of simple components Users group components to form larger components Line Rect. Graphic Add(Graphic) Remove(Graphic) GetChild(int) Text Primitive graphical objects Aggregate of Graphic objects graphics Picture Add(Graphic) Remove(Graphic) GetChild(int) forall g in graphics g.

Composite Pattern Example A simple implementation defines classes for graphical primitives (e.g. Text and lines) plus other classes that act as containers for these primitives The problem is user must treat primitive and container objects differently Having to distinguish these objects makes applications more complex Line Rect. Graphic Add(Graphic) Remove(Graphic) GetChild(int) Text Picture Add(Graphic) Remove(Graphic) GetChild(int) graphics forall g in graphics g.

Composite Pattern Example Key is an abstract class that represents both primitives and their containers Graphic Add(Graphic) Remove(Graphic) GetChild(int) Graphic declares operations such as draw that are specific to graphical objects Also operations for accessing and managing children Line Rect. Text Picture Add(Graphic) Remove(Graphic) GetChild(int) graphics forall g in graphics g.

Structure of Composite Pattern Client Manipulates objects in the composition through Component interface Component Operation() Add(Component) Remove(Component) GetChild(int) Declares interface for objects and child components Defines behavior for primitive objects. Leafs have no children Leaf Operation() Defines behavior for components having children. Implements child-related operations Composite children Operation() Add(Component) Remove(Component) GetChild(int) forall g in children g.operation()