10 likes | 107 Views
package framework; abstract class Figure { /** @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() { … } }.
E N D
package framework; abstract class Figure { /** @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() { … } } package figures; class Square extends Figure { private int size; /** @vsf drawing */ public void draw() { … } } framework/Figure>draw(Graphics) framework/Figure>g figures/Circle>draw(Graphics) framework/Figure>draw() figures/Square>draw(Graphics) figures/Circle>draw() figures/Square>draw() class framework/Figure { /** @vsf drawing */ protected Graphics g; /** @vsf drawing */ public void draw(Graphics g) { … } } class figures/Circle { /** @vsf drawing */ public void draw(Graphics g) { … } } class figures/Square { /** @vsf drawing */ public void draw(Graphics g) { … } } Programming With Crosscutting Effective Views Define a Set of Program Elements Update Source Files 1 5 • 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. • 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 cross-sections of their code while maintaining its full object-oriented structure and without the need for additional language features. 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 • 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 4 2 class framework/Figure { /** @vsf drawing */ protected Graphics g; /** @vsf drawing */ public void draw() { … } } class figures/Circle { /** @vsf drawing */ public void draw() { … } } class figures/Square { /** @vsf drawing */ public void draw() { … } } Parse VSF Render 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. • 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 • each block of • text belongs • to. Edit VSF 3 Doug Janzen dsjanzen@cs.ubc.ca Kris De Volder kdvolder@cs.ubc.ca Software Practices Lab Department of Computer Science University of British Columbia Vancouver, BC Canada • The user can add, change, and delete elements in the virtual • source file.