Automatically Extracting and Verifying Design Patterns in Java Code James Norris Ruchika Agrawal Computer Science Department Stanford University {jcn,

Slides:



Advertisements
Similar presentations
Design Patterns.
Advertisements

Welcome to. Who am I? A better way to code Design Patterns ???  What are design patterns?  How many are there?  How do I use them?  When do I use.
©Ian Sommerville 2000 Software Engineering, 6th edition. Chapter 12Slide 1 Software Design l Objectives To explain how a software design may be represented.
18-1 Verifying Object Behavior and Collaboration Role playing – the act of simulating object behavior and collaboration by acting out an object’s behaviors.
Automated creation of verification models for C-programs Yury Yusupov Saint-Petersburg State Polytechnic University The Second Spring Young Researchers.
Object-Oriented Analysis and Design
Design Patterns for Object Oriented systems CSC 515 Ashwin Dandwate.
1 © Wolfgang Pelz UML3 UML 3 Notations describe how to use reusable software. Package Component Deployment Node.
Patterns Lecture 2. Singleton Ensure a class only has one instance, and provide a global point of access to it.
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
Recall The Team Skills 1. Analyzing the Problem (with 5 steps) 2. Understanding User and Stakeholder Needs 3. Defining the System 4. Managing Scope 5.
Design Patterns CS is not simply about programming
Marakas: Decision Support Systems, 2nd Edition © 2003, Prentice-Hall Chapter Chapter 7: Expert Systems and Artificial Intelligence Decision Support.
Design Patterns Module Name - Object Oriented Modeling By Archana Munnangi S R Kumar Utkarsh Batwal ( ) ( ) ( )
Object-oriented design CS 345 September 20,2002. Unavoidable Complexity Many software systems are very complex: –Many developers –Ongoing lifespan –Large.
ECE450 - Software Engineering II1 ECE450 – Software Engineering II Today: Design Patterns VI Composite, Iterator, and Visitor Patterns.
CERN – European Organization for Nuclear Research GS Department – Administrative Information Services Design Patterns in Groovy Nicolas Décrevel Advanced.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
UML Sequence Diagrams Michael L. Collard, Ph.D. Department of Computer Science Kent State University.
OOSE 01/17 Institute of Computer Science and Information Engineering, National Cheng Kung University Member:Q 薛弘志 P 蔡文豪 F 周詩御.
Design Patterns Discussion of pages: xi-11 Sections: Preface, Forward, Chapter
Design Patterns Standardized Recurring model Fits in many location Opposite of customization Fundamental types of pattern Choose and use as desired and.
Katanosh Morovat.   This concept is a formal approach for identifying the rules that encapsulate the structure, constraint, and control of the operation.
Software Design Refinement Using Design Patterns Instructor: Dr. Hany H. Ammar Dept. of Computer Science and Electrical Engineering, WVU.
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Unified Modeling Language, Version 2.0
Design Patterns in Java Chapter 1 Introduction Summary prepared by Kirk Scott 1.
Programming in Java Unit 3. Learning outcome:  LO2:Be able to design Java solutions  LO3:Be able to implement Java solutions Assessment criteria: 
SOFTWARE DESIGN AND ARCHITECTURE LECTURE 27. Review UML dynamic view – State Diagrams.
DESIGN PATTERNS CSC532 Adv. Topics in Software Engineering Shirin A. Lakhani.
18 April 2005CSci 210 Spring Design Patterns 1 CSci 210.
Software Design Patterns (1) Introduction. patterns do … & do not … Patterns do... provide common vocabulary provide “shorthand” for effectively communicating.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
1 Qualitative Reasoning of Distributed Object Design Nima Kaveh & Wolfgang Emmerich Software Systems Engineering Dept. Computer Science University College.
ECE450S – Software Engineering II
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Unified Modeling Language. Object Oriented Methods ► What are object-oriented (OO) methods?  OO methods provide a set of techniques for analyzing, decomposing,
Introduction to Design Patterns. Questions What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared.
Object-Oriented Modeling: Static Models. Object-Oriented Modeling Model the system as interacting objects Model the system as interacting objects Match.
Behavioral Patterns CSE301 University of Sunderland Harry R Erwin, PhD.
Copyright © Active Frameworks Inc. - All Rights Reserved - V2.0Design Pattern Catalog - Page L3-1 PS95&96-MEF-L10-1 Dr. M.E. Fayad Creationa.
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
Design Patterns Introduction
CS251 – Software Engineering Lectures 18: Intro to DP Slides by Rick Mercer, Christian Ratliff, Oscar Nierstrasz and others 1 و ابتغ فيما آتاك الله الدار.
1 Technical & Business Writing (ENG-715) Muhammad Bilal Bashir UIIT, Rawalpindi.
1 Unified Modeling Language, Version 2.0 Chapter 2.
Chapter 5 System Modeling. What is System modeling? System modeling is the process of developing abstract models of a system, with each model presenting.
Software Engineering Laboratory, Department of Computer Science, Graduate School of Information Science and Technology, Osaka University 1 Extracting Sequence.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Concept mining for programming automation. Problem ➲ A lot of trivial tasks that could be automated – Add field Patronim on Customer page. – Remove field.
Design and implementation Chapter 7 – Lecture 1. Design and implementation Software design and implementation is the stage in the software engineering.
Fall 2007 Week 9: UML Overview MSIS 670: Object-Oriented Software Engineering.
Object Oriented Programming and Data Abstraction Earl Huff Rowan University.
Basic Characteristics of Object-Oriented Systems
CLASSIFICATION OF DESIGN PATTERNS Hladchuk Maksym.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Slide 1 Unified Modeling Language, Version 2.0 Object-Oriented SAD.
Examples (D. Schmidt et al)
Chapter 0: Introduction
Chapter 10 Design Patterns.
Software Design Patterns
Design Patterns Lecture part 2.
Introduction to Design Patterns
Lecture 2 of Computer Science II
Object-Oriented Analysis
Software Engineering Lecture 7 - Design Patterns
Software Design Lecture : 14.
From Use Cases to Implementation
Presentation transcript:

Automatically Extracting and Verifying Design Patterns in Java Code James Norris Ruchika Agrawal Computer Science Department Stanford University {jcn,

1. Overview  The goal of this proposal is to outline a project designed to extract well established design patterns in object-oriented software using static analysis and report violations of the patterns using dynamic analysis.  We hope to develop a tool that will extract design patterns from Java programs of various sizes and complexity, and report violations to aid programmers in ensuring that their usage of design patterns is correct.

Motivation  Designing object-oriented software is no trivial task, and software bugs are prevalent.  Design patterns offer a pre-thought out, pre-tested solution to day-to-day problems object-oriented designers and programmers face  Yet,programmers may inadvertently implement or use design patterns incorrectly, which may result in various types of bugs (some very subtle ones as discussed in our case study).

Applications  Industry programmers could use our tool to verify that they have implemented and used various design patterns correctly.  By extracting design patterns, we will be decomposing large programs into meaningful components, on which further types of analyses may be applied for optimization or correctness purposes.

The Challenges  designing the analysis needed to extract the design patterns  as complexity of design patterns increases, making it harder to extract them, the complexity of the analysis necessary to detect violations also increases  Programmers sometimes intentionally implement slight variations of design patterns

RELATED WORK

Christian Kramer and Lutz Prechelt, Design Recovery by Automated Search for Structural Design Patterns in Object-Oriented Software  extract design information directly from C++ header files and store them as Prolog facts  design patterns – specifically Adapter, Bridge, Composite, Decorator, and Proxy -- are encoded as Prolog rules  Prolog query is used to search for all patterns; the results show 40% precision

Federico Bergenti and Agostino Poggi, Improving UML Designs Using Automatic Design Pattern Detection  finding and improving the realizations of design patterns in UML diagrams

Niere, Wadsack and Zundorf, Recovering UML Diagrams from Java Code using Patterns  use fuzzy pattern detection techniques to recover UML collaboration diagrams from source code  detect simple instances of collaboration between individual classes and not the more complex semantics of generic design patterns  use annotation engines run over abstract syntax trees to detect code cliches and utilizes a particular form of fuzzy logic, generic fuzzy reasoning networks, to detect distorted or varying code cliches

Jagdish Bansiya, Automating Design-Pattern Identification  Algorithm (not described) is based on structural information: interfaces (abstract classes), base classes and subclasses, template classes, inheritance relationships, aggregation by physical containment of instance variables, aggregation by references/pointer instance variables, and method parameter-based uses relationships

Kyle Brown, Design Reverse-Engineering and Automated Design Pattern Detecting in Smalltalk  Infers type information and uses program traces to extract patterns from Smalltalk programs  pattern is detectable if its template solution is both distinctive and unambiguous  algorithm to detect patterns relies on a common set of design information representable by the class diagrams and object-message diagrams utilized and extracts this information from Smalltalk code

John Whaley, Michael Martin and Monica Lam, Automatic Extraction of Object- Oriented Component Interfaces  extract object-oriented component interfaces  use: multiple finite state machine (FSM) submodels to model the interface of a class, which includes methods that access particular fields, for example; dynamic instrumentation techniques to extract FSM models from execution runs; and static analyses to deduce illegal call sequences in a program, and a dynamic model checker to ensure that the code conforms to the model  Want to use their techniques to detect role-based patterns such as Iterator

SIMPLE DESIGN PATTERNS  Examples: Adapter, Bridge, Decorator, Proxy, Singleton, Visitor  techniques relying on structural information from static analysis and work well to extract structural design patterns

COMPLEX DESIGN PATTERNS  Examples: Facade, Interpreter, Composite, Iterator, Chain of Responsibility  Often requires analysis of runtime behavior and code semantics

SIMPLE CASE STUDY: THE SINGLETON DESIGN PATTERN  Only one instance of an object should be created during a program’s lifetime  Can use heuristics such as private constructors, public static final instance variables to recognize  Look for common violations of patterns with static and dynamic analyses

NEXT STEPS

Design Pattern Specification  Provide an interface that programmers can use to specify new design pattern models or modify existing ones

Extracting More Simple Patterns and Detecting Violations  attach probabilities to the various criteria used to recognize patterns in order to derive a confidence rating for each pattern extraction  Machine learning techniques could be used to optimize those probabilities based on training data derived from manually examining classes or dynamically instrumenting code to detect particular design patterns  examine available structural information not used by the pattern criteria and try to detect commonalities between classes implementing the patterns that could suggest additional pattern criteria or anti-criteria  use multiple FSM submodels to extract some of the role-based patterns such as Iterator or State

Extracting More Complex Patterns and Detecting Violations  apply dynamic analyses to extract more complex patterns and report violations of them  for example, we may want to try tracing method invocation histories across objects to detect patterns such as Chain of Responsibility, Decorator, and other complex behavioral patterns

Other Extensions  suggest improvements to design pattern implementation in addition to reporting violations  report violations with a certain level of confidence  rank the detected violations