1 / 20

Interfaces, Aspects, and Views

Interfaces, Aspects, and Views. David Shepherd Dr. Lori Pollock University of Delaware. Example task. Given: Source code to JHotDraw, an open source drawing framework Context: Just coded CompositeFigure recently, but not updating correctly Task: Investigate and fix.

aisha
Télécharger la présentation

Interfaces, Aspects, and Views

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

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

  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) rectangle coordinates (6,5) Subject notify() Observer refresh screen

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

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

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

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

  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. 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. Symptoms of Inconsistent Implementation • Decreased code quality • Decreased reliability • Decreased maintainability • (Possibly) missing functionality

  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. Technique - Aspect Miner...(AMAV) • 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 Class A Class B Class C Class D cacheMe persistB persistD willChange changed change cache persistC doCache getSize

  13. Aspect MinerAnd 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 AMAV changed willChange doChange

  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. Plug-In-Hugger Paul - Step 1 • Goes to CompositeFigure • Suspects composite is part of the Observer design pattern, because implements FigureChangedListener

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

  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. Charlie Examines Refactoring Opportunities • Browse through Cluster View... • Find (in top 15) VSF

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

  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/

More Related