Programming With Crosscutting Effective Views The Problem Decomposition
Programming With Crosscutting Effective Views The Problem • Decomposition of programs in terms of classes and in terms of crosscutting concerns are both useful, but languages based on source files allow only a single decomposition. 5 Update Source Files The tool analyzes the differences between the Input Set I and the Output Set O to determine how the source files should be modified: Added elements: A=O–I Removed elements: R = I – O Same elements: S=I∩O A Solution • Use a tool that lets developers create virtual source files (VSFs) by gathering together declarations from multiple classes. • Virtual source files are effective views in that editing them results in corresponding changes being made to the original source code. • VSFs let developers edit crosssections of their code while maintaining its full objectoriented structure and without the need for additional language features. Doug Janzen Software Practices Lab dsjanzen@cs. ubc. ca Department of Computer Science University of British Columbia Kris De Volder Vancouver, BC kdvolder@cs. ubc. ca Canada 1 package framework; abstract class Figure { Define a Set of Program Elements The user creates a set of element identifiers called the Input Set by: • Using comment tags, or • Selecting elements from a browser, or • Writing a query /** @vsf drawing */ protected Graphics g; /** @vsf drawing */ public abstract void draw(); } package figures; class Circle extends Figure{ public int radius; /** @vsf drawing */ public void draw() { … } } framework/Figure>draw(Graphics) package figures; class Square extends Figure { figures/Circle>draw(Graphics) private int size; figures/Square>draw(Graphics) /** @vsf drawing */ public void draw() { … } framework/Figure>g framework/Figure>draw() figures/Circle>draw() } figures/Square>draw() 4 Parse VSF • The tool parses the virtual source file to produce the Output Set. • Unlike normal source files, VSFs must be parseable in order to be saved. class framework/Figure { /** @vsf drawing */ protected Graphics g; /** @vsf drawing */ public void draw(Graphics g) { … } /** @vsf drawing */ public void draw() { … } } class figures/Circle { /** @vsf drawing */ public void draw(Graphics g) { … } } class figures/Square { /** @vsf drawing */ public void draw(Graphics g) { … } } /** @vsf drawing */ public void draw() { … } } 2 Render VSF • The tool creates a virtual source file by retrieving the source code for every element in the Input Set. • Special syntax is used to identify which source file 3 each block of • The user can add, change, and delete elements in the virtual text belongs source file. to. Edit VSF
- Slides: 1