24
Software Maintenance Object Flow Graphs – Part II 1 Object Flow Graphs (Part II) [email protected]

Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II1

Object FlowGraphs(Part II)

[email protected]

Page 2: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II2

Outline

§ Repetition§ Program abstraction§ Graph creation§ Containers

§ NEW§ Object sensitivity§ Improvement of class diagrams

Page 3: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II3

Outline

§ Repetition§ Program abstraction§ Graph creation§ Containers

§ NEW§ Object sensitivity§ Improvement of class diagrams

Page 4: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II4

Why do we create

Object Flow Graphs?

Page 5: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II5

Original Program

Abstract Program

Object Flow Graph

Activities

Page 6: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II6

LanguageAbstraction

Page 7: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

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)

Page 8: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II8

Example 4

Page 9: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II9

Example

4

Page 10: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II10

Graph

Creation

Page 11: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II11

Outline

§ Repetition§ Program abstraction§ Graph creation§ Containers

§ NEW§ Object sensitivity§ Improvement of class diagrams

Page 12: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II12

Container

Container

C

Object

C.add(Object)

Object=C.get()

ObjectC = ObjectObject = C

Page 13: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II13

Outline

§ Repetition§ Program abstraction§ Graph creation§ Containers

§ NEW§ Object sensitivity§ Improvement of class diagrams

Page 14: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

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

Page 15: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

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

Page 16: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

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.

Page 17: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II17

Outline

§ Repetition§ Program abstraction§ Graph creation§ Containers

§ NEW§ Object sensitivity§ Improvement of class diagrams

Page 18: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II18

Class diagram recovery I

Page 19: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II19

Class diagram recovery II

Page 20: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II20

Howdo we

improve the Class Diagram?

Page 21: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

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.

Page 22: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

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);;

Page 23: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II23

Control of Study Objectives

Page 24: Object Flow Graphs - ist.tugraz.at€¦ · Software)Maintenance 2 Object)Flow)Graphs)– Part)II Outline! Repetition! Program)abstraction! Graph)creation! Containers! NEW! Object)sensitivity!

Software MaintenanceObject Flow Graphs – Part II24

Questions?