17 Example of software change Application framework Drawlets –adds graphical display to a host...

38
17 Example of software change • Application framework Drawlets – adds graphical display to a host application • Drawing canvas – lines, free-hand lines, rectangles, rounded rectangles, triangles, pentagons, polygons, ellipses, text boxes, images © 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 1

description

The host application Responsible for providing an instance of the drawing canvas, toolbars, and tool buttons Class SimpleApplet is a host application –is a part of the Drawlet library –SimpleApplet runs in any browser © 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 173

Transcript of 17 Example of software change Application framework Drawlets –adds graphical display to a host...

Page 1: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

17 Example of software change

• Application framework Drawlets – adds graphical display to a host application

• Drawing canvas – lines, free-hand lines, rectangles, rounded

rectangles, triangles, pentagons, polygons, ellipses, text boxes, images

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 1

Page 2: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Drawlets - features

• More than 100 classes, 35 interfaces and 40,000 lines of code– originally implemented by Kent Beck, Ward

Cunningham– later ported into Java– “perfect API”

– http://www.rolemodelsoft.com/aboutUs/ drawlets.htm

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 2

Page 3: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

The host application

• Responsible for providing an instance of the drawing canvas, toolbars, and tool buttons

• Class SimpleApplet is a host application – is a part of the Drawlet library – SimpleApplet runs in any browser

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 3

Page 4: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

SimpleApplet window

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 4

Page 5: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Top classes

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 5

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

LabelTool

Figure

Page 6: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Change Request

• Implement an owner for each figure. – An owner is the user who put the figure onto the

canvas, and only the owner should be allowed to modify it.

– At the beginning of a session, the users input their ID and password and they are the owners of all figures that were created during the session.

• This change will make SimpleApplet more versatile and useful– support for cooperative work

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 6

Page 7: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Concepts

• Implement an owner for each figure. – An owner is the user who put the figure onto

the canvas, and only the owner should be allowed to modify it.

– At the beginning of a session, the users input their ID and password and they are the owners of all figures that were created during the session

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 7

Page 8: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Concept classification

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 8

irrelevant external significant implement x owner x figure x user x canvas x allowed x modify x beginning x session input x ID x password x created x

Page 9: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Locating figure properties

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 9

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

LabelTool

Figure

Page 10: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Wrong way

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 10

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

LabelTool

Figure

Page 11: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Backtrack

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 11

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

LabelTool

Figure

Page 12: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Right way

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 12

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

LabelTool

Figure

Page 13: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Wrong way

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 13

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

LabelTool

Figure

Page 14: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Backtrack

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 14

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

LabelTool

Figure

Page 15: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Summary

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 15

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

LabelTool

Figure

Page 16: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Actualization

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 16

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

OwnerIdentity

SimpleListener

LabelTool

Figure

Page 17: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Change propagation

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 17

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

OwnerIdentity

SimpleListener

LabelTool

Figure

Page 18: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Propagation - 1

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 18

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

OwnerIdentity

SimpleListener

LabelTool

Figure

Page 19: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Propagation - 2

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 19

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

OwnerIdentity

SimpleListener

LabelTool

Figure

Page 20: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Propagation - 3

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 20

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

OwnerIdentity

SimpleListener

LabelTool

Figure

Page 21: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Propagation - 4

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 21

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

OwnerIdentity

SimpleListener

LabelTool

Figure

Page 22: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Propagation - 5

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 22

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

OwnerIdentity

SimpleListener

LabelTool

Figure

Page 23: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Propagation - 6

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 23

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

OwnerIdentity

SimpleListener

LabelTool

Figure

Page 24: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Propagation - done

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 24

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

OwnerIdentity

SimpleListener

LabelTool

Figure

Page 25: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Unit Tests

• 385 unit tests• 1369 assertions • 4800 lines.

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 25

Page 26: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Functional tests

• Draw– figure drawn on the canvas, for all figures

• Select – figure is selected

• Move – figure is moved to a different location

• . . .– 141 functional test cases

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 26

Page 27: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Creation of functional tests

• Record/playback tool for Java applications • Tool Abbot used to run the functional tests

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 27

Page 28: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Phase of actualization

• New unit tests for new classes • New functional tests for the new

functionality• During the change propagation, the old

tests that were impacted by the change were updated.

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 28

Page 29: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Test suite maintenance

• Tests from the old version that are not affected by the change are kept as regression tests for the future

• Obsolete tests are removed• Tests of the new features are added after

the change

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 29

Page 30: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Results

• Base line– production code 17800 lines – unit test code 4800 lines.

• Change– 91 lines of production code (0.5%) were

modified– 124 lines (2.5%) of the test code– approximately 1.4 test code lines per modified

production code line.

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 30

Page 31: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Refactoring

• Long change propagation is a problem• it would be advantageous to shorten it

• Refactoring can shorten the change propagation • move code affected by change into fewer

classes• split the roles

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 31

Page 32: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Propagation

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 32

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

OwnerIdentity

SimpleListener

LabelTool

Figure

Page 33: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Moving the code

• Each class that creates new figures has the function basicNewFigure(...) – two main parts:

• create a new figure • if the figure was created at wrong location, move it

• We refactored a new method called moveFigure(...)– made it a member of the base class ConstructionTool

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 33

Page 34: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Refactoring impact

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 34

SequenceOfFigures

ShapeTool

EllipseToolRectangleTool RectangularCreationTool PG_RectImageTool

Locator

CanvasTool

AbstractFigure

SimpleDrawingCanvas

DrawingCanvas

ToolPalette

SimpleApplet

ToolBar

LocatorConnectionHandle

PrototypeConstructionTool

SelectionTool ConstructionTool

StylePalette

LabelTool

Figure

Page 35: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Splitting of roles

• Same method used in two different roles– the same code can do both jobs

• Propagating change highlights the differences– only one of the roles needs to be updated – the other one can stay unchanged– splitting the two roles and updating only one

of them shortens the propagation

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 35

Page 36: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Splitting the roles

• Function move(...) in AbstractFigure is used in two ways– to move the figure as requested by the user

• must check user identity– as a part of the new figure creation

• does not need to check user identity

• We split move(...)and secureMove(…)

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 36

Page 37: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Numerical data

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 37

No refactoring Move function Splitting

Classes added 2 2 2

Interfaces modified

1 1 1

Classes modified

13 8 5

LOC modified

91 95 87

Page 38: 17 Example of software change Application framework Drawlets –adds graphical display to a host application Drawing canvas –lines, free-hand lines, rectangles,

Conclusions

• Splitting up a method into two similar methods may require least work

• Minus: A new set of unit tests must be created, thus test code is duplicated.

• Minus: More effort is required to create new tests compared to the effort required to adapt existing tests to their changed implementation.

• Possible problem: Does Role splitting strategy lead to system degeneration?

© 2012 Václav Rajlich Software Engineering: The Current Practice Ch. 17 38