Design Pattern Detection

Similar documents
Design Pattern Detection

Design Patterns. Gunnar Gotshalks A4-1

Design Patterns. An introduction

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

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

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

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

Lecture 13: Design Patterns

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

Coordination Patterns

MSO Exam November 7, 2016, 13:30 15:30, Educ-Gamma

Information Systems Analysis and Design. XIV. Design Patterns. Design Patterns 1

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

Topics in Object-Oriented Design Patterns

Design Patterns V Structural Design Patterns, 2

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

CS/CE 2336 Computer Science II

Adapter Pattern Structural

Design Patterns

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

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

Design Patterns! Acknowledgements!

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

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

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

INSTITUTE OF AERONAUTICAL ENGINEERING

CISC 322 Software Architecture

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

Implementing GUI context-sensitive help... ECE450 Software Engineering II. Implementing GUI context-sensitive help... Context-sensitive help

Design Pattern and Software Architecture: IV. Design Pattern

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

Introduction to Patterns and Frameworks

Object-Oriented Oriented Programming Adapter Pattern

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

C++ (Non for C Programmer) (BT307) 40 Hours

17. GRASP: Designing Objects with Responsibilities

Inheritance. EEC 521: Software Engineering. Dealing with Change. Polymorphism. Software Design. Changing requirements Code needs to be flexible

A Reconnaissance on Design Patterns

2.1 Design Patterns and Architecture (continued)

Assigning Responsibilities (Patterns of Responsibility Assignment Principles: GRASP)

An Introduction to Patterns

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

Software Engineering with Objects and Components Open Issues and Course Summary

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

CSE870: Advanced Software Engineering (Cheng) 1

Overview of Patterns: Introduction

Object Oriented. Analysis and Design

Design Patterns Reid Holmes

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

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

Programmazione. Prof. Marco Bertini

Foundations of Software Engineering Design Patterns -- Introduction

2.1 Design Patterns and Architecture (continued)

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

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

Design Patterns Revisited

ADAPTER. Topics. Presented By: Mallampati Bhava Chaitanya

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

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

CSCU9T4: Managing Information

Programmazione. Prof. Marco Bertini

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

GRASP: Patterns for. chapter18

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles

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

Design Pattern: Composite

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

Object oriented programming Concepts

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING

Work groups meeting 3

Chapter 12 (revised by JAS)

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

MSO Lecture 12. Wouter Swierstra (adapted by HP) October 26, 2017

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

Cocoa Design Patterns. Erik M. Buck October 17, 2009

Design Patterns: Elements of Reusable Object Oriented Software. Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides

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

1 of 27 9/27/2001 5:34 PM

Design Patterns. Paul Jackson. School of Informatics University of Edinburgh

Summary of the course lectures

Verification and Validation. Ian Sommerville 2004 Software Engineering, 7th edition. Chapter 22 Slide 1

Part 5. Verification and Validation

DESIGN PATTERN MATCHING

Lecture Material. Design Patterns. Visitor Client-Server Factory Singleton

Patterns and Testing

May Comp-B 11, Advanced Software Design. 3 hours duration

CSC7203 : Advanced Object Oriented Development. J Paul Gibson, D311. Design Patterns

Design Patterns in C++

Introduction to UML. (Unified Modeling Language)

FACADE & ADAPTER CSCI 4448/5448: OBJECT-ORIENTED ANALYSIS & DESIGN LECTURE 7 09/13/2011

Introduction to Design Patterns

12 Tutorial on UML. TIMe TIMe Electronic Textbook

Tecniche di Progettazione: Design Patterns

Reuse at Design Level: Design Patterns

GRASP Design Patterns A.A. 2018/2019

Introduction to Design Patterns

State Pattern. CSIE Department, NTUT Woei-Kae Chen. State: Intent. Allow an object to alter its behavior when its internal state changes.

Unit Wise Questions. Unit-1 Concepts

Chapter 8: Enhanced ER Model

EGF Tutorial Reuse and Customization

Transcription:

Design Pattern Detection

Design Patterns EECS 6431 Design Pattern Detection 2/22 A design pattern systematically names, explains and evaluates an important and recurring design problem and its solution Good designers know not to solve every problem from first principles They reuse solutions This is very different from code reuse

Design Patterns - Definition From the Gang of Four textbook EECS 6431 Design Pattern Detection 3/22 Design patterns are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context

Essential Elements of a Design Pattern EECS 6431 Design Pattern Detection 4/22 Name Naming a pattern increases our design vocabulary Problem When to apply the pattern Solution Elements that make up the design, their relationships, responsibilities, and collaborations Consequences Results and trade-offs of applying the pattern

How Design Patterns Solve Design Problems EECS 6431 Design Pattern Detection 5/22 Finding appropriate objects Determining object granularity Specifying object interfaces Specifying object implementations Putting reuse mechanisms to work Inheritance vs. Composition Delegation Designing for change

Pattern Benefits EECS 6431 Design Pattern Detection 6/22 Enable large scale reuse of software architectures Explicitly capture expert knowledge and design trade-offs Help improve developer communication Help ease the transition to OO methods

Pattern Drawbacks EECS 6431 Design Pattern Detection 7/22 Patterns do not lead to direct code reuse Patterns are often deceptively simple You may suffer from pattern overload Patterns must be validated by experience and debate rather than automated testing Integrating patterns into a process is human intensive rather than a technical activity

Pattern Description Template EECS 6431 Design Pattern Detection 8/22 Name Intent What does the pattern do? What problems does it address? Motivation A scenario of pattern applicability Applicability In which situations can this pattern be applied Participants Describe participating classes/objects

Pattern Description Template (cont.) EECS 6431 Design Pattern Detection 9/22 Collaborations How do the participants carry out their responsibilities? Diagram Graphical representation of the pattern Consequences How does the pattern support its objectives? Implementation Pitfalls, language specific issues Examples

Classification EECS 6431 Design Pattern Detection 10/22 Structural Deal with decoupling interface and implementation of classes and objects Behavioural Deal with dynamic interaction among collections of classes and objects Creational Deal with initializing and configuring collections of classes and objects

Detecting design patterns EECS 6431 Design Pattern Detection 11/22 A difficult task Patterns are primarily a literary form No rigorous mathematical definitions Automatic detection beyond the state of the art of Artificial Intelligence Instead, detect the artifacts of implementing the solution of the design pattern Purely structural patterns are easier to detect Purely behavioural patterns are much harder Most patterns are somewhere in the middle

Template solution EECS 6431 Design Pattern Detection 12/22 A template solution needs to be both Distinctive The static structure is not likely to be represented in a design that does not use the pattern Unambiguous Can only be done in one way (or in a small number of variants) An object adapter is unambiguous but not distinctive

Object Adapter Static Structure EECS 6431 Design Pattern Detection 13/22 Client Target request() Adapter request() adaptee Adaptee specificrequest() adaptee.specificrequest()

Composite vs. Decorator EECS 6431 Design Pattern Detection 14/22 A Decorator is sometimes referred to as a degenerate Composite. The static structure of the two patterns is very similar The dynamic behaviour is also the same Static difference: A Composite contains a collection of Components, while a Decorator contains only one Intent difference: The Composite pattern groups components into a whole. The Decorator patterns enhances the responsibility of a component.

State vs. Strategy EECS 6431 Design Pattern Detection 15/22 Both patterns allow flexible choice from a set of alternatives In their simple variants, the static structure and the dynamic behaviour are exactly the same The difference: Choosing a particular behaviour (State) vs. choosing a particular algorithm (Strategy)

Analysis synergy EECS 6431 Design Pattern Detection 16/22 Both static and dynamic analysis are necessary in order to detect patterns Static analysis The static structure of the pattern has to match a subgraph of the static structure of the software system Dynamic analysis Message passing during run-time has to match the message flow that implements the behaviour of the pattern

Design Pattern Instances EECS 6431 Design Pattern Detection 17/22 Each design pattern has a fixed set of roles, e.g. in the Adapter pattern, there is a Client, a Target, an Adapter, and an Adaptee Every detection technique attempts to discover instances of the design pattern in the software system being examined A design pattern instance is a set of classes that match the roles

Design Pattern Detection Research Issues EECS 6431 Design Pattern Detection 18/22 False positive elimination The precision of most published approaches is quite poor, often below 50% Dealing with Variants Patterns are conceptual. Their implementation may vary considerably depending on the specific context Counting instances Different detection approaches do it differently

Detecting Design Patterns in Java software with PDE EECS 6431 Design Pattern Detection 19/22 PDE is a tool that collects static and dynamic facts from a system written in Java and detects design patterns in it

PDE - Static analysis EECS 6431 Design Pattern Detection 20/22 Every pattern has a static definition, e.g. uses client target inherits adapter target uses adapter adaptee Javex and grok are used to extract static facts such as uses ClassA ClassB inherits ClassC ClassB uses ClassC ClassD QL matches the static definition to the static facts

EECS 6431 Design Pattern Detection 21/22 PDE - Dynamic analysis Every pattern has a dynamic definition in XML <entry classname="adapter" calledbyclass="client" thisobject="object1" nextcallinsubtree="yes"> <entry classname="adaptee" calledbyclass="adapter" calledbyobject="object1" thisobject="object2"> </entry> </entry>

EECS 6431 Design Pattern Detection 22/22 PDE - Dynamic analysis Probekit is used to collect dynamic facts such as <entry calledbyclass="contactadapter" calledbymethod="settitle" calledbyobject="contactadapter@145" classname="chovnatlhimpl" methodname="cherpatlh" thisobject="chovnatlhimpl@110"> If the dynamic facts do not match the dynamic definition the candidate instance is deemed a false positive