Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware.

Similar presentations


Presentation on theme: "1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware."— Presentation transcript:

1 1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware

2 2 Given: Source code to JHotDraw, an open source drawing framework Context: Just coded CompositeFigure recently, but not updating correctly Task: Investigate and fix Example task...

3 3 Observer Pattern in JHotDraw Observer (Display Area) must be notified when Subject (Rectangle) changes Display Area rectangle coordinates (1,5) rectangle coordinates (6,5) refresh screen rectangle coordinates (6,5) Subject Observer notify()

4 4 Coder Charlie - Step 1 Looks in CompositeFigure Suspects it is part of the Observer design pattern because implements FigureChangedListener

5 5 Coder Charlie - Step 2 Follows type hierarchy to AbstractFigure − Because of knowledge of design pattern, suspects notify() (from Design Patterns) is there

6 6 Coder Charlie - Step 3 Goes to AbstractFigure Looks for notify() Can you find it?

7 7 Coder Charlie - Step 3 cont'd notify() = changed()

8 8 Coder Charlie - Step 4 Goes back to CompositeFigure Realizes should add call to changed() to figureChanged() 1/2 of the job done right − needs to add willChange() too

9 9 Problem Cross-cutting concerns are often not implemented consistently Code added throughout lifecycle Different programmers Forgetfulness Unknown policy/convention Even when explicit, as interface

10 10 Symptoms of Inconsistent Implementation Decreased code quality Decreased reliability Decreased maintainability (Possibly) missing functionality

11 11 Our Goal Improve implementation of cross-cutting concerns + Without increasing burden on programmer + Without large computational demands at user interaction time Introducing... Aspect Miner And Viewer (AMAV)

12 12 Class DClass CClass B Technique - Aspect Miner...(AMAV) Class A change cacheMepersistD doCache persistB changed willChange persistC getSize cache Cluster related methods Pluggable similarity metric Simple Natural Language Processing (NLP) technique Sub-string (method name) matching Cluster related methods Pluggable similarity metric Simple Natural Language Processing (NLP) technique Sub-string (method name) matching

13 13 Aspect Miner And Viewer (AMAV) Show closely related methods in Virtual Source File (VSF) − Allows programmer to learn from other methods − Leads to consistency Use tool for... − Initial coding, bug squashing − Refactoring opportunities VSF changed doChange willChange AMAV

14 14 Using AMAV During Implementation New Coder: Plug-In-Hugger Paul − "I LUUUUUUV AMAV!" Same task − Given: JHotDraw, an open source drawing framework − Context: Just coded CompositeFigure recently, but they are not updating correctly − Task: Investigate and fix AMAV Plug-in

15 15 Goes to CompositeFigure Suspects composite is part of the Observer design pattern, because implements FigureChangedListener Plug-In-Hugger Paul - Step 1

16 16 Plug-In-Hugger Paul - Step 2a-c Find figureChanged in ClusterViewer Look at closely related methods Follow their patterns New implementation consistent VSF

17 17 Task Results Why is Paul so happy? He finished before poor Charlie He had an easier time than Charlie He won the company award for high quality code (he had a more consistent and correct implementation) − Best Parking Space

18 18 Charlie Examines Refactoring Opportunities Browse through Cluster View... Find (in top 15) VSF

19 19 Charlie Examines Refactoring Opportunities Browse through Cluster View... Find (in top 15) VSF

20 20 Conclusion AMAV clusters related methods across classes − NLP-based similarity − Pluggable metric (possibly n dimensions) AMAV integrates mining and viewing AMAV helps with maintenance, implementation, evolution Paul is home sleeping while Charlie is still at work, fixing his code For details: www.cis.udel.edu/~shepherd/


Download ppt "1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware."

Similar presentations


Ads by Google