1 interfaces, aspects, and views david shepherd dr. lori pollock university of delaware

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

Upload: britton-cain

Post on 18-Dec-2015

215 views

Category:

Documents


0 download

TRANSCRIPT

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

1

Interfaces, Aspects, and Views

David ShepherdDr. Lori Pollock

University of Delaware

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

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 . . .

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

3

Observer Pattern in JHotDraw

Observer (Display Area) must be notified when Subject (Rectangle) changes

Display Area

rectanglecoordinates(1,5)

rectanglecoordinates

(6,5)

refresh screen

rectanglecoordinates

(6,5)Subject

Observer

notify()

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

4

Coder Charlie - Step 1

• Looks in CompositeFigure

• Suspects it is part of the Observer design pattern because implements FigureChangedListener

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

5

Coder Charlie - Step 2

• Follows type hierarchy to AbstractFigure −Because of knowledge of

design pattern, suspects notify() (from Design Patterns) is there

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

6

Coder Charlie - Step 3

• Goes to AbstractFigure

• Looks for notify()

• Can you find it?

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

7

Coder Charlie - Step 3 cont'd

• notify() = changed()

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

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

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

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

Lori Pollock
I would change title to The Problemsince you just showed the problem in the excellent example you did!
Page 10: 1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware

10

Symptoms of Inconsistent Implementation

• Decreased code quality

• Decreased reliability

• Decreased maintainability

• (Possibly) missing functionality

Lori Pollock
I would title this The Symptomsand then say what you have as the much longer title now.
Page 11: 1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware

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)

Lori Pollock
Eliminate bullet since you only have one bullet.Change the others to plus signs as they are what you want as characteristics of the solution and separate them more to take up more of the slide.I would replace use-time by run-time
Page 12: 1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware

12

Class DClass CClass B

Technique - Aspect Miner...(AMAV)

Class A

change

cacheMe persistD

doCache

persistB

changedwillChange

persistC

getSize

cache

•Cluster related methods•Pluggable similarity metric

•Simple Natural Language Processing (NLP) technique•Sub-string (method name) matching

Lori Pollock
- they will wonder what A.V. represents,so maybe just say Aspect Miner on this slide and introduce AMAV on next slide after seen this one.- to avoid two uses of "metric" on the left, useSimple NLP techniquewhat goes at the bottom of the slide under vector space?
Page 13: 1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware

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

doChangewillChange AMAV

Lori Pollock
They may not know what VSF is. need to spell out.Need to use same form of verb in bullets at same level - Allows... LeadsThe figure at the bottom doesn't tell me anything the way it is drawd. Maybe if methods in different boxes on left to show in different files and then show together in VSF box, and edges going from left to AMAV and from AMAV to VSF box to show that AMAV produces the VSF.
Page 14: 1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware

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 AMAVPlug-in

Lori Pollock
Instead of the figure there now, use a figure to represent AMAV that you used in the previous slide. Maybe show AMAV and a stick figure called Paul hugging the AMAV? or just Paul with AMAV.
Page 15: 1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware

15

• Goes to CompositeFigure

• Suspects composite is part of the Observer design pattern, because implements FigureChangedListener

Plug-In-Hugger Paul - Step 1

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

16

Plug-In-Hugger Paul - Step 2a-c

•Find figureChanged in ClusterViewer•Look at closely related methods•Follow their patterns•New implementation consistent

VSF

Lori Pollock
You call it ClusterViewer for the first time here.You called it VSF before. Need to make sure the reader knows they are the same thing, probably by using the same name VSF here or ClusterViewer earlier.
Page 17: 1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware

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

Lori Pollock
Change title to:Why is Plug-in Hugger Paul so Happy? and have Paul with a happy faceThen text is:- He finished before poor Charlie- He had an easier time than Charlie- He won the company programming award for a moreconsistent (correct) implementation.
Page 18: 1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware

18

Charlie Examines Refactoring Opportunities•Browse through Cluster

View...

•Find (in top 15)VSF

Lori Pollock
Change title to:Charlie examines Refactoring Opportunitiesand say Charlie is going for the next award, realizing he has a great tool to work with compared to his colleagues.
Page 19: 1 Interfaces, Aspects, and Views David Shepherd Dr. Lori Pollock University of Delaware

19

Charlie Examines Refactoring Opportunities•Browse through Cluster

View...

•Find (in top 15)VSF

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

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/

Lori Pollock
This slide should say something different than prevous slides. Either summarize the kinds of applications/uses of AMAV not already shown through the example. Or, give the points listed as the advantages in the paper in section 2, putting it into context with the state of the art. You have not talked about anyone else's tools to put this into context yet. They should see that somewhere.Also, maybe a cite or something about how the clustering is done would be good to at least mention, maybe a slide that cites your other papers to read for the details on how the clustering is done. So, this talk has been an advertisement for AMAV. Now, you want them to understand there is research driving the tool and where do they read about the research.