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

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

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

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

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

Topics in Object-Oriented Design Patterns

CS/CE 2336 Computer Science II

Design Patterns V Structural Design Patterns, 2

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

Design Patterns

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

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

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

Design Patterns! Acknowledgements!

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

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

INSTITUTE OF AERONAUTICAL ENGINEERING

CISC 322 Software Architecture

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

Adapter Pattern Structural

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

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

A Reconnaissance on Design Patterns

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

Introduction to Patterns and Frameworks

17. GRASP: Designing Objects with Responsibilities

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

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

An Introduction to Patterns

Design Patterns Reid Holmes

Assigning Responsibilities (Patterns of Responsibility Assignment Principles: GRASP)

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

2.1 Design Patterns and Architecture (continued)

Overview of Patterns: Introduction

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

Design Patterns Revisited

CSE870: Advanced Software Engineering (Cheng) 1

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

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

Object-Oriented Oriented Programming Adapter Pattern

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

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

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

Foundations of Software Engineering Design Patterns -- Introduction

GRASP: Patterns for. chapter18

2.1 Design Patterns and Architecture (continued)

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

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

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

Work groups meeting 3

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

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

Object Oriented. Analysis and Design

Programmazione. Prof. Marco Bertini

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

Summary of the course lectures

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

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

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

ADAPTER. Topics. Presented By: Mallampati Bhava Chaitanya

CS251 Software Engineering Lectures 18: Intro to DP

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

Programmazione. Prof. Marco Bertini

CSCU9T4: Managing Information

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

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

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

SDC Design patterns GoF

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

Design Pattern: Composite

Using Design Patterns in Java Application Development

An Introduction to Patterns

Reuse at Design Level: Design Patterns

Design Patterns in C++

Review Software Engineering October, 7, Adrian Iftene

Object oriented programming Concepts

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

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

GRASP Design Patterns A.A. 2018/2019

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

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

Chapter 12 (revised by JAS)

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

CISC 323 Intro to Software Engineering

Lecture 20: Design Patterns II

192. Design Patterns in Java Software

The Design Patterns Matrix From Analysis to Implementation

From Design Patterns: Elements of Reusable Object Oriented Software. Read the sections corresponding to patterns covered in the following slides.

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

EINDHOVEN UNIVERSITY OF TECHNOLOGY

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

Composite Pattern. IV.4 Structural Pattern

Transcription:

Design Pattern Detection

Design Patterns 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 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 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 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 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 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 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.) 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 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 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 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 Client Target request() Adapter request() adaptee Adaptee specificrequest() adaptee.specificrequest()

Composite vs. Decorator 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 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 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 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 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 PDE is a tool that collects static and dynamic facts from a system written in Java and detects design patterns in it It will be installed on indigo by the end of the month A possible course project is to apply PDE to an open source system and evaluate the results

PDE - Static analysis 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

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>

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

Results with sample pattern implementations PDE detects 22/23 patterns Except Facade, all patterns are detected Facade is more an architectural design pattern PINOT detects 17/23 Pattern definitions are hard coded FUJABA detects 14/23 Behavioral patterns hard to detect

PDE Full Results