Authors: Khaled Abdelsalam Mohamed Amr Kamel

Slides:



Advertisements
Similar presentations
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Object-Oriented.
Advertisements

Automated Analysis and Code Generation for Domain-Specific Models George Edwards Center for Systems and Software Engineering University of Southern California.
NaLIX: A Generic Natural Language Search Environment for XML Data Presented by: Erik Mathisen 02/12/2008.
Automatically Extracting and Verifying Design Patterns in Java Code James Norris Ruchika Agrawal Computer Science Department Stanford University {jcn,
Michael Ernst, page 1 Improving Test Suites via Operational Abstraction Michael Ernst MIT Lab for Computer Science Joint.
Common Mechanisms in UML
Methodology Conceptual Database Design
Object Oriented Analysis By: Don Villanueva CS 524 Software Engineering I Fall I 2007 – Sheldon X. Liang, Ph. D.
Practical Object-Oriented Design with UML 2e Slide 1/1 ©The McGraw-Hill Companies, 2004 PRACTICAL OBJECT-ORIENTED DESIGN WITH UML 2e Chapter 2: Modelling.
Design Patterns.
Katanosh Morovat.   This concept is a formal approach for identifying the rules that encapsulate the structure, constraint, and control of the operation.
Ontology Development Kenneth Baclawski Northeastern University Harvard Medical School.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
05 - Patterns Intro.CSC4071 Design Patterns Designing good and reusable OO software is hard. –Mix of specific + general –Impossible to get it right the.
Introduction to MDA (Model Driven Architecture) CYT.
An Introduction to Design Patterns. Introduction Promote reuse. Use the experiences of software developers. A shared library/lingo used by developers.
Copyright 2002 Prentice-Hall, Inc. Modern Systems Analysis and Design Third Edition Jeffrey A. Hoffer Joey F. George Joseph S. Valacich Chapter 20 Object-Oriented.
Database Management System Prepared by Dr. Ahmed El-Ragal Reviewed & Presented By Mr. Mahmoud Rafeek Alfarra College Of Science & Technology Khan younis.
CS3773 Software Engineering Lecture 04 UML Class Diagram.
Team Think For You. Outline  Introduction  Process  Requirements Engineering  Architecture  Detailed Design  Testing  Demo  Extensibility  Conclusions.
Domain Modeling Part2: Domain Class Diagram Chapter 4 pp part 2 1.
Unified Modeling Language © 2002 by Dietrich and Urban1 ADVANCED DATABASE CONCEPTS Unified Modeling Language Susan D. Urban and Suzanne W. Dietrich Department.
ECE450S – Software Engineering II
Understanding and using patterns in software development EEL 6883 Software Engineering Vol. 1 Chapter 4 pp Presenter: Sorosh Olamaei.
Design Model Lecture p6 T120B pavasario sem.
Introduction to Design Patterns. Questions What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared.
CPSC 871 John D. McGregor Module 5 Session 1 Design Patterns.
Ch- 8. Class Diagrams Class diagrams are the most common diagram found in modeling object- oriented systems. Class diagrams are important not only for.
Software Engineering Zhang Shuang
Review of Parnas’ Criteria for Decomposing Systems into Modules Zheng Wang, Yuan Zhang Michigan State University 04/19/2002.
Progress Report - Year 2 Extensions of the PhD Symposium Presentation Daniel McEnnis.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Class Diagrams. Terms and Concepts A class diagram is a diagram that shows a set of classes, interfaces, and collaborations and their relationships.
Object-Oriented Software Engineering Practical Software Development using UML and Java Modelling with Classes.
Copyright © 2009 Pearson Education, Inc. Publishing as Prentice Hall Appendix A Object-Oriented Analysis and Design A.1.
The PLA Model: On the Combination of Product-Line Analyses 강태준.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
Design Patterns: MORE Examples
Unified Modeling Language (UML)
Object-Oriented Modeling
Chapter 1: Introduction to Systems Analysis and Design
Chapter 10 Design Patterns.
Systems Analysis and Design With UML 2
Introduction to Design Patterns
Chapter 11 Object-Oriented Design
Programming Languages and Compilers (CS 421)
CMPE 135: Object-Oriented Analysis and Design October 24 Class Meeting
TIM 58 Chapter 8: Class and Method Design
Designing Software for Ease of Extension and Contraction
Model-Driven Analysis Frameworks for Embedded Systems
Domain Class Diagram Chapter 4 Part 2 pp
Software Engineering Lecture #11.
Informatics 122 Software Design II
Generation Gap By Kurt Rehwinkel
Chapter 20 Object-Oriented Analysis and Design
Appendix A Object-Oriented Analysis and Design
Analysis models and design models
Software Design Lecture : 14.
Chapter 1: Introduction to Systems Analysis and Design
Visual Modeling Using Rational Rose
CMPE 135 Object-Oriented Analysis and Design March 21 Class Meeting
Introduction to Design Patterns
Automated Analysis and Code Generation for Domain-Specific Models
Inheritance and Polymorphism
Chapter 8, Design Patterns Introduction
Object Oriented Design & Analysis
Appendix A Object-Oriented Analysis and Design
Chapter 1: Introduction to Systems Analysis and Design
UML  UML stands for Unified Modeling Language. It is a standard which is mainly used for creating object- oriented, meaningful documentation models for.
Computer Science II for Majors
Presentation transcript:

Authors: Khaled Abdelsalam Mohamed Amr Kamel Reverse Engineering State and Strategy Design Patterns using Static Code Analysis Authors: Khaled Abdelsalam Mohamed Amr Kamel

Software Development Continuous changes Bug fixing New features Requirements/Technological

Software Development Development team can also change New team members may need to learn from scratch Hard to know every implementation detail

Software Development Development team can also change New team members may need to learn from scratch Documentation becomes vital Tedious to keep updated

Software Development There have been many techniques to ease legacy code insight and understanding

Legacy/Undocumented code Design patterns have specific intentions Leads to understanding the usage of different parts of the software

Legacy/Undocumented code How can we extract design patterns from software? Decorator Strategy Observer State

The techniques Analysis type Search Methodology How to map the software properties Search Methodology How to search those properties

The techniques Analysis type: Structural analysis: Recovers Class relationships, method signatures, compositions etc. Proxy, Decorator, Adapter etc.

The techniques Analysis type: Structural analysis: Recovers Class relationships, method signatures, compositions etc. Proxy, Decorator, Adapter etc. Behavioral analysis: Recovers the components actions of the software. Iterator, State, Observer etc.

The techniques Analysis type: Structural analysis: Recovers Class relationships, method signatures, compositions etc. Proxy, Decorator, Adapter etc. Behavioral analysis: Recovers the components actions of the software. Iterator, State, Observer etc. Semantic analysis: Supplements both. Uses naming conventions.

The techniques Search Methodology: Database queries: Code is mapped with metadata structures

The techniques Search Methodology: Database queries: Code is mapped with metadata structures Constraint Resolver: Code Is mapped with addition of constraints and roles

The techniques Search Methodology: Database queries: Code is mapped with metadata structures Constraint Resolver: Code Is mapped with addition of constraints and roles XPG formalism and parsing: Source code mapped as a visual language

The techniques Search Methodology: Database queries: Code is mapped with metadata structures Constraint Resolver: Code Is mapped with addition of constraints and roles XPG formalism and parsing: Source code mapped as a visual language Code UML structures used to derive metrics. Found metrics compared against the expected metrics of a given Design Pattern

The techniques Static Analysis Dynamic Analysis Process to analyze code by deriving information from the source code Dynamic Analysis Derive information from running software Static Analysis -> Can be done in incomplete code

The techniques Static Analysis Process to analyze code by deriving information from the source code

The techniques Static Analysis Dynamic Analysis Process to analyze code by deriving information from the source code Dynamic Analysis Derive information from running software

The techniques Static Analysis Dynamic Analysis Process to analyze code by deriving information from the source code Dynamic Analysis Derive information from running software Static Analysis -> Can be done in incomplete code

The approach Use Static code analysis to find design patterns Program dependency Control dependency Data dependency

The approach The code is mapped as a graph Design patterns graphs are matched to code generated graph

The approach The Joern Platform was modified to also save class hierarchy Graph data persisted with Neo4j Gremlin to query the data Joern

The approach - Steps 1. Load source code

The approach - Steps 1. Load source code 2. Code property graph Joern

The approach - Steps Joern 1. Load source code 2. Code property graph 3. Save graph in Neo4j DB Joern

4. Add Design Patterns Attributes The approach - Steps 1. Load source code 2. Code property graph 3. Save graph in Neo4j DB 4. Add Design Patterns Attributes Joern

4. Add Design Patterns Attributes The approach - Steps 1. Load source code 2. Code property graph 3. Save graph in Neo4j DB 4. Add Design Patterns Attributes 5. Select Design Pattern Joern

The approach - Steps Joern 1. Load source code 2. Code property graph 3. Save graph in Neo4j DB 4. Add Design Patterns Attributes 5. Select Design Pattern 6. Load Design Pattern Matching Queries Joern

The approach - Steps Joern 1. Load source code 2. Code property graph 3. Save graph in Neo4j DB 4. Add Design Patterns Attributes 5. Select Design Pattern 6. Load Design Pattern Matching Queries 7. Run Queries Joern

The approach - Steps Joern 1. Load source code 2. Code property graph 3. Save graph in Neo4j DB 4. Add Design Patterns Attributes 5. Select Design Pattern 6. Load Design Pattern Matching Queries 7. Run Queries 8. Display Graph Matching Patterns results Joern

The approach State and Strategy design patterns issue Similar structure Different behavior

State and Strategy design patterns issue Similar structure Different behavior vs

State and Strategy design patterns issue

Metadata graph enrichment Methods to Classes Link between classes and their methods (Joern misses)

Metadata graph enrichment Methods to Classes Link between classes and their methods (Joern misses) Inheritance Adds the relation between Super class and their subclasses

Metadata graph enrichment Methods to Classes Link between classes and their methods (Joern misses) Inheritance Adds the relation between Super class and their subclasses Abstract (Virtual) Methods With body No body

Metadata graph enrichment Class Aggregates Class

Metadata graph enrichment Class Aggregates Class Link between classes aggregating other classes Method Creates Class Link between a method and the class of the object it instantiates

Metadata graph enrichment Class Aggregates Class Link between classes aggregating other classes Method Creates Class Link between a method and the class of the object it instantiates Method Overrides Method Link between methods overriding each other

Metadata graph enrichment Class Aggregates Class Link between classes aggregating other classes Method Creates Class Link between a method and the class of the object it instantiates Method Overrides Method Link between methods overriding each other Method Calls Method Link between a caller method and the method called

Solving the State and Strategy issue Step 1 Find State and Strategy candidates Step 2 Differentiate State and Strategy candidates

Differentiating State and Strategy candidates Loop each pattern candidate Find class aggregations variables (let’s call it X) Use find methods M that use variables X Check if methods M includes subclasses from pattern candidates If c is truth then the candidate is a State design Check if methods from c includes client method from pattern candidates If f is true then the candidate is a strategy

Authors Conclusion Successfully use Code Property Graph to map Design patterns Able to differentiate Strategy and State Uses only static analysis As future work Make catalogue of all relationships and properties of design patterns Support multiple graph pattern variants

Paper critique Abstract and Introduction Deviated from the described a Approach Focus in the Strategy/State No mention of qualitative/quantitative study

My Conclusion Needs to evaluate the approach Practical idea Constrain Test on well know good code (e.g, Linux Kernel on Github) Practical idea Constrain Needs well written code that uses design pattern

References https://refactoring.guru/design-patterns/strategy Kniesel, Gunter and Binun, Alexander, "Standing on the shoulders of giants- a data fusion approach to design pattern detection," in Program Comprehension, 2009. ICPC'09. IEEE 17th International Conference on, 2009. T. A. Ghaleb, "The role of open source software in program analysis for reverse engineering," 2016 2nd International Conference on Open Source Software Computing (OSSCOM), Beirut, 2016, pp. 1-6. doi: 10.1109/OSSCOM.2016.7863684 G. Costagliola and G. Polese, "Extended positional grammars," Proceeding 2000 IEEE International Symposium on Visual Languages, Seattle, WA, 2000, pp. 103-110. doi: 10.1109/VL.2000.874373