Upload
others
View
4
Download
0
Embed Size (px)
Citation preview
Software MaintenanceObject Flow Graphs – Part II2
Outline
§ Repetition§ Program abstraction§ Graph creation§ Containers
§ NEW§ Object sensitivity§ Improvement of class diagrams
Software MaintenanceObject Flow Graphs – Part II3
Outline
§ Repetition§ Program abstraction§ Graph creation§ Containers
§ NEW§ Object sensitivity§ Improvement of class diagrams
Software MaintenanceObject Flow Graphs – Part II4
Why do we create
Object Flow Graphs?
Software MaintenanceObject Flow Graphs – Part II5
Original Program
Abstract Program
Object Flow Graph
Activities
Software MaintenanceObject Flow Graphs – Part II6
LanguageAbstraction
Software MaintenanceObject Flow Graphs – Part II7
Language Abstraction
§ Data flow sensitive§ Fully scoped identifiers § Class members: package.class.id§ Method parameters: package.class.method.id
§ Control flow insensitive§ Ignore/Remove§ Primitive data types § Constants (even null)
Software MaintenanceObject Flow Graphs – Part II8
Example 4
Software MaintenanceObject Flow Graphs – Part II9
Example
4
Software MaintenanceObject Flow Graphs – Part II10
Graph
Creation
Software MaintenanceObject Flow Graphs – Part II11
Outline
§ Repetition§ Program abstraction§ Graph creation§ Containers
§ NEW§ Object sensitivity§ Improvement of class diagrams
Software MaintenanceObject Flow Graphs – Part II12
Container
Container
C
Object
C.add(Object)
Object=C.get()
ObjectC = ObjectObject = C
Software MaintenanceObject Flow Graphs – Part II13
Outline
§ Repetition§ Program abstraction§ Graph creation§ Containers
§ NEW§ Object sensitivity§ Improvement of class diagrams
Software MaintenanceObject Flow Graphs – Part II14
Object sensitivity
§ Distinguish objects§ belonging to the same class§ but of different instances
§ Construction§ more complicated§ more precise propagation of information
Software MaintenanceObject Flow Graphs – Part II15
Example
1. x = new Object();2. y = new Object();
Object.this
x
y
Object1.this x
yObject2.this
Object-insensitive Object-sensitive
Software MaintenanceObject Flow Graphs – Part II16
Example
3
1. public class BinaryTreeNode 2. BinaryTreeNode left, right ;;3. Comparable obj;;4. public BinaryTreeNode (Comparable x ) 5. obj = x;; 6. 7. public class ToyCollection8. static Set toys = new TreeSet ();;9. public static void addToy (Toy t)10. BinaryTreeNode n = new BinaryTreeNode (t);;11. toys.insert(n);; 12. public static void main ()13. Toy t = new Toy("PS2”);;14. addToy(t);; 15. 16. public class Toy implements Comparable17. Object id;;18. public Toy( )19. id = null;; 20. public void name (Object name) 21. id = name;;22.
Software MaintenanceObject Flow Graphs – Part II17
Outline
§ Repetition§ Program abstraction§ Graph creation§ Containers
§ NEW§ Object sensitivity§ Improvement of class diagrams
Software MaintenanceObject Flow Graphs – Part II18
Class diagram recovery I
Software MaintenanceObject Flow Graphs – Part II19
Class diagram recovery II
Software MaintenanceObject Flow Graphs – Part II20
Howdo we
improve the Class Diagram?
Software MaintenanceObject Flow Graphs – Part II21
Control of Study Objectives1. public class Animal2. String name;;3. public Animal(String name)4. this.name = name;;5. 6.
7. public class Zoo8. List animals = new ArrayList();;9. public static void addAnimal(String name)10. Animal a = new Animal(name);;11. animals.add(a);;12. 13. public static void main(String[] args)14. String garfield = “Garfield”;;15. addAnimal(garfield);;16. 17.
1) Generieren Sie das Abstrakte Programmund den OFG.
2) Zeichnen Sie das Klassendiagramm auf und zeigen Siegrafisch welcheVerbesserungen Siedurch den OFG erzielen können.
Software MaintenanceObject Flow Graphs – Part II22
Control of Study Objectives2. Animal.name3. Animal.Animal(Animal.Animal.name)4. Animal.name = Animal.Animal.name;;8. Zoo.animals = new ArrayList.ArrayList();;9. Zoo.addAnimal(Zoo.addAnimal.name)10. Zoo.addAnimal.a = new Animal.Animal(Zoo.addAnimal.name);;11. Zoo.animals = Zoo.addAnimal.a;;13. Zoo.main(Zoo.main.args)14. Zoo.main.garfield = new String.String();;15. Zoo.main.this. Zoo.addAnimal(Zoo.main.garfield);;
Software MaintenanceObject Flow Graphs – Part II23
Control of Study Objectives
Software MaintenanceObject Flow Graphs – Part II24
Questions?