overview - cs.columbia.edueaddy/fxpal.pdf · .net is language agnostic c#, but also jscript,...

67

Upload: others

Post on 25-Aug-2020

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue
Page 2: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Overview

Situated Awareness

•EyeGuide

Extensibility

•Scripting

Modularity

•Measuring

• Improving

Marc Eaddy 2

Page 3: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

SITUATED AWARENESS

Page 4: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

EyeGuide

□ Subway map(public display)

□ Lost user

□ Nefariousstraphangers

□ EyeGuide “steers” user’s gaze tomap locationsusing whispered verbal cues

4M. Eaddy, G. Blaskó, J. Babcock, S. Feiner, “My Own Private Kiosk: Privacy-Preserving Public Displays,” International Symposium on Wearable Computers (ISWC), 2004.

Page 5: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

EyeGuide Contributions

□ Introduces private “gaze steering”

□ Maps

□ Paintings

□ Sculpture

□ “Secret ServiceMan”

□ Lightweight eye- and head-tracking headgear Marc Eaddy 5

Page 6: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

IMPROVING SOFTWARE EXTENSIBILITY

Page 7: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

ThomsonONE

□ Distributed, multi-threaded, event-based desktop application

□ I was system architect, lead developer, supervisor

□ Voted “Product of the Year” by Inside Market Data

Marc Eaddy 7

Real-time stock market data

Page 8: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

ThomsonONE scripting

□ VBScript, JavaScript, etc.

□ Associate scripts with app events

Marc Eaddy 8

Page 9: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

ThomsonONE scripting

□ VBScript, JavaScript, etc.

□ Associate scripts with app events

□ Powerful object model

□ Flexible end-user customization

□ Rapid prototypingMarc Eaddy 9

Page 10: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Goblin

10

Platform for AR, VR, and 3D apps and games

Page 11: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Goblin features

□ Written using C# and Managed DirectX□ Scene graph

□ Animation□ Collision detection□ Pathfinding AI

□ Devices□ Sony optical see-through head-worn displays□ 6DOF device abstraction□ InterSense 6DOF tracking devices□ EssentialReality gloves

□ Innovative runtime environment□ “Scripting”□ Edit-and-continue

Marc Eaddy 11

Page 12: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Goblin extensibility

□ Source files are “scripts”□ .NET is language agnostic

□C#, but also JScript, Python, Perl, etc.

□ High performance□Compiled, not interpreted

□No glue code

□ Edit-and-continue (demo)□ Edit source files while app is running

□ Changes compiled in the background

Marc Eaddy 12

M. Eaddy, S. Feiner, “Multi-Language Edit-and-Continue for the Masses,” Columbia University Technical Report CUCS-015-05, 2005.

Page 13: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

IMPROVING SOFTWARE MODULARITY

Page 14: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Modular design

□ Arguably most important design property

□ Reduces complexity□ Separation of concerns [Dijkstra]

□ Modular reasoning

□ Information hiding [Parnas]

□ Independent development/testing□ Programming by contract (interfaces)

□ Reusability and substitutability□ Abstract data types [Liskov]

□ Low coupling and high cohesion [Steven, Myers, Constantine]

Marc Eaddy 14

Dividing program into self-contained subprograms (modules)

Page 15: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Concerns

□ Features, requirements, design patterns, code idioms, etc.

□ Raison d'être for code

□ Every line of code exists to satisfy some concern

Marc Eaddy 15

Anything that affects the implementation of a program (informal definition)

Page 16: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

The crosscutting concern problem

□ Code related to the concern is…

□ Scattered across (crosscuts) multiple files

□ Often tangled with other concern code

□ Degrades overall modularity

Marc Eaddy 16

Some concerns difficult to modularize

Page 17: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Example: Pathfinding in Goblin

□ Pathfinding is modularizedMarc Eaddy 17

Page 18: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Example: Collision Detection

□ Collision detection not modularizedMarc Eaddy 18

Page 19: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Impact on software quality□ Modularity is degraded□ Program harder to understand

□ “Where is collision detection implemented?”□ “What is this code for?”□ “What features will be affected by this change?”

□ Program harder to evolve□ Be careful to update all locations□ Changes not localized

□ Bottom line

Marc Eaddy 19

Page 20: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

My research

□ Crosscutting concern problem poorly understood□ Hard to evaluate “solutions”□ How big is the problem? (i.e., $1K or $1B? – Aho)□ Few formal studies

□ Determine impact of crosscutting concerns on software quality□ Formalize problem

□ “A problem defined is half the solution" – Kachigan

□ Quantify impact

□ Find solutions

Marc Eaddy 20

Page 21: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Quantifying the problem

□ Concern metrics

□ Degree of scattering – a modularity measure

□ Degree of tangling – measures separation of concerns

□ Concern location

□ Hard to locate the code that implements a concern

□>50% of maintenance time

□ Our tools: ConcernTagger and Cerberus

21M. Eaddy, A. Aho, G.C. Murphy, “Identifying, Assigning, and Quantifying Crosscutting Concerns,” Workshop on Assessment of Contemporary Modularization Techniques (ACOM), 2007

Page 22: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue
Page 23: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue
Page 24: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Cerberus

□ Hybrid automated concern location technique

□ Information retrieval (IR)

□ Execution tracing (tracing)

□ Prune dependency analysis (PDA)

Marc Eaddy 24

M. Eaddy, A. Aho, G. Antoniol, Y.-G. Guéhéneuc, “CERBERUS: Tracing Requirements to Source Code Using Information Retrieval, Dynamic Analysis, and Program Analysis,” International Conference on Program Comprehension (ICPC) (to appear), 2008.

Three experts are better than one (and two)

Page 25: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

IR-based concern location

□ i.e., Google for code

□ Program entities are documents

□ Requirements are queries

□ Term extraction□ Parse code and reqs spec to extract terms

□ Synonym and abbreviation expansion

□ Weigh terms based on local and global frequency (tf-idf)

□ Similarity = cosine distance between document and query vectors

□ Requires meaningful identifier names

Marc Eaddy 25

Page 26: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Tracing-based concern location

□ Observe elements activated when concern is exercised

□ Unit tests for each concern

□ Relevance = tests for concern that activate element e / tests that activate element e

□ Tests must be complete and exclusive

□ Exercise all inputs for one concern only

Marc Eaddy 26

Page 27: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

PDA-based concern location

□ Infer relevant elements based on relationship to relevant element e (seed)

□ Prune dependency analysis

□ Find references to e

□ Find dominators and dominatees of e

□ Find superclasses and subclasses of e

□ Requires good seeds

□ Everything is dominated by Main

Marc Eaddy 27

M. Eaddy, A. Aho, G.C. Murphy, “Identifying, Assigning, and Quantifying Crosscutting Concerns,” Workshop on Assessment of Contemporary Modularization Techniques (ACOM), 2007

Page 28: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Information Retrieval

Prune Dependency

Analysis

Trace Ranking

IRRanking

Execution Tracing

Combined Ranking

Seed ExtractionConcern

Descriptions

ConcernTests

SourceCode

InitialRelevant Elements

FinalRelevant Elements

Cerberus

Marc Eaddy 28

Page 29: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Cerberus Effectiveness

29

0.0

0.1

0.2

0.3

0.4

0.5

0.6

0.7

0 50 100 150 200 250 300 350

F-M

easu

re

Number of Concerns Located by Technique

IR + Tracing + PDA

("CERBERUS")

IR + PDA

IR + Tracing

IR

Tracing + PDA

Tracing

Cerberus

Page 30: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Do crosscutting concerns cause defects?

□ Created mappings□ Requirement–code map

□ Bug–code map

□ Bug–requirement map (inferred)

□ Correlated scattering, concern size, and bug count□ Spearman correlation

M. Eaddy, T. Zimmermann, K.D. Sherwood, V. Garg, G.C. Murphy, N. Nagappan, A. Aho, “Do Crosscutting Concerns Cause Defects?,” Transactions on Software Engineering (TSE) (to appear), 2008.

Project Language Size (KLOC)

Mylyn–Bugzilla Java 13

Rhino Java 44

iBATIS Java 13

30

Page 31: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Do crosscutting concerns cause defects?

□ Found moderateto strong correlationbetween scattering and defects

□ As scattering increases so do defects

□ Tangling appears unrelated to defects

Marc Eaddy 31

Page 32: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

How widespread is the problem?

□ 5 case studies of OO programs□ Scattering

□ Concerns related to 6 classes on average□ OO unsuitable for representing problem domain

□ Most (86%) concerns are crosscutting to some extent□ Dispels “modular base” notion□ General-purpose solution needed

□ Tangling□ Classes related to 10 concerns on average□ Poor separation of concerns

□ Classes doing too much

□ Crosscutting concerns severely limit modularity

Marc Eaddy 32

Page 33: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

IMPROVING SOFTWARE MODULARITY

Page 34: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Aspect-oriented programming

□ An aspect

□ Class-like construct

□ Rules for

□ Injecting code into other methods

□Adding members to existing classes (i.e. open classes)

□ Aspect code localized in one file—effects many files

Marc Eaddy 34

Inject code at specific points in the program (essentially)

Page 35: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Wicca#

□ Wicca#□ Extends C#

□ Aspect annotations

□ Open class annotations

□ Statement annotations

□ Side classes (future work)

□ Wicca□ Wicca# “ecosystem”

□ Tools and runtime

Marc Eaddy 35

Classes

Page 36: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Wicca

□ Extends C# tool chain

□ wsc – Wicca# preprocessor/compiler

□ Phx.Morph – Post-compile tool

□ wdbg – Debugger

Marc Eaddy 36

M. Eaddy, A. Aho, W. Hu, P. McDonald, J. Burger, “Debugging Aspect-Enabled Programs,” Symposium on Software Composition (SC), 2007.

M. Eaddy, “Phx.Morph: Why hasn't Microsoft adopted Aspect-Oriented Programming?,” Invited Talk, Microsoft AOP Goes .NET Workshop, 2005.

M. Eaddy, “Phx.Morph: Weaving using the Microsoft Phoenix compiler back-end,” Demo, Aspect-Oriented Software Development (AOSD), 2006.

Page 37: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Wicca

□ Extends runtime environment

□ wicca – Command-line shell

□Dynamic aspect-oriented programming

□Dynamic software updating

□Edit-and-continue

Marc Eaddy 37

M. Eaddy, “Wicca 2.0: Dynamic Weaving using the .NET 2.0 Debugging APIs,” Demo, Aspect-Oriented Software Development (AOSD), 2007.

Page 38: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Weaving

AssembliesAssembliesProjects

VM

Build

Info

C#C#

App’

Front-end

Binary Weaver

Breakpoint Weaver

Debugger

HostVM

a

b

ICorDbgCal

lback

ICorDbg

Wicca

Hosted App

AssembliesAssemblies

App’’

IL +

MD

De

ltas

Jo

inp

oin

t Bre

akp

oin

tsSource Weaver

Compiler

Preprocessor

Wicca architecture

38

Page 39: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Static transformation pipeline

Marc Eaddy 39

Deltas

WovenProgram

BreakPoints

Wicca#Compiler

Phx.Morph

AspectAssemblies

CompiledProgram

SourceFiles

C# Compiler Phoenix

Page 40: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Example: SimpleDraw

□ SimpleDraw draws shapes on a display

□ Naïve implementation couples Shape and Display concerns

Marc Eaddy 40

public init() {s = new Shape[3];s[0] = new Point(10, 10);s[1] = new Point(5, 5);s[2] = new Line(new Point(1, 9),

new Point(9, 1));for (int i = 0; i < s.Length; i++)

Display.instance().addShape(s[i]);Display.instance().update();

SimpleDraw.cspublic void moveBy(int dx, int dy) {x += dx;y += dy;Display.instance().update();

public void moveBy(int dx, int dy) {a.moveBy(dx, dy);b.moveBy(dx, dy);Display.instance().update();

Point.cs

Line.cs

Page 41: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Example: SimpleDraw

□ SimpleDraw draws shapes on a display

□ Naïve implementation couples Shape and Display concerns

Marc Eaddy 41

public init() {s = new Shape[3];s[0] = new Point(10, 10);s[1] = new Point(5, 5);s[2] = new Line(new Point(1, 9),

new Point(9, 1));for (int i = 0; i < s.Length; i++)

Display.instance().addShape(s[i]);Display.instance().update();

SimpleDraw.cspublic void moveBy(int dx, int dy) {x += dx;y += dy;Display.instance().update();

public void moveBy(int dx, int dy) {a.moveBy(dx, dy);b.moveBy(dx, dy);Display.instance().update();

Point.cs

Line.cs

Page 42: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Display updating aspectclass DisplayUpdating {

[Advice(AdviceType.after, "execution(void Shape.moveBy)")]

[Advice(AdviceType.after, "execution(void Point.moveBy)")]

[Advice(AdviceType.after, "execution(void Line.moveBy)")]

static public void updateAfterMove() {

Display.instance().update();

}

}

Marc Eaddy 42

Page 43: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Statement annotations

□ Concerns with “irregular” implementations

□ Error handling, assertions, optimizations, logging

□ Hard to modularize using regular aspects

□ Apply aspects to specific locations,statements, or object instances

43

Difficult to modularize irregular concern code

M. Eaddy, A. Aho, “Statement Annotations for Fine-Grained Advising,” Workshop on Reflection, AOP and Meta-Data for Software Evolution (RAM-SE), 2006.

[NonNull] AuthorizationRequest ar =

new AuthorizationRequest(this, dest);

Page 44: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Future Work

□ Reduce crosscutting□ Side classes

□ Improve concern location□ Improve program analysis precision□ Use machine learning to combine judgments□ Incorporate smart “grep” and PDA into IDE

□ Gather empirical evidence□ Impact of reducing crosscutting□ Impact of crosscutting on maintenance effort□ Impact of code tangling on quality

Marc Eaddy 44

Page 45: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Conclusion□ Powerful software

extensibility mechanisms

□ Dangers of poor concernmodularity

□ Improving concernmodularity

Marc Eaddy

Classes

Page 46: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Acknowledgements

□ Alfred Aho

□ Gobin□ Erik Petterson

□ John Waugh

□ Hrvoje Benko

□ Wicca□ Boriana Ditcheva

□ Rajesh Ramakrishnan

□ Adam Vartanian

□ ConcernTagger/ConcernMapper□ Vibhav Garg

□ Martin Robillard

□ Frédéric Weigand-Warr

□ Cerberus□ Giuliano Antoniol

□ Yann-Gaël Guéhéneuc

□ Microsoft Phoenix Team

Marc Eaddy 46

Page 47: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Questions?

Marc Eaddy

Columbia University

[email protected]

Page 48: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

ThomsonONE

48

Page 49: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Main Thread

Control’sThread

Quote

DispatchThread

Queued Object

Waiting

Wrapper

Event Queue

Scripting

Script Engine

Event Sink(Quote)

ThomsonONEscriptingMarc Eaddy 49

Page 50: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

50

App.exe

Patcher(Patcher.dll)

Common Language Runtime

Watcher(Watcher.exe)

Common

Language Runtime

Source

Files

Incremental

Build File

Post-Edit

Module

reads

watches

reads

builds

edits

process

boundary

Legend

File I/O

API Call

socket

communication

Metadata

(Current)

C# Application

Current Assembly

reads &

appends

replaces

Profiler & Metadata

APIs

socket

communication

startsOld code of

foo()

foo()

IL_0000:72

IL_0005:72

New code of

foo()

foo()

IL_0000:72

IL_0005:72

Metadata

(Post-Edit)

App-01.exe

App.

exe.incrfoo.cs

Edit-and-continue

Page 51: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Phx.Morph architecture

51

Phx.Morph

EditorsOpen Classes, binary and breakpoint weaving

Phoenix-specific AOP

Attribute Handlers

Phoenix

PEREWAssembly

Re-Writer

Phx.Aop

AOPJoinpoints, pointcuts, …

AttributesCustom AOP annotations

.NET

Morph

Plugin

Page 52: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Confounding effect of size□ Larger concerns are

buggier

□ Scattering, size, and bug count strongly interrelated□ Is scattering just measuring

the “size effect”?

□ Control for size usingcovariant analysis□ Step-wise regression

□ Principal component analysis

□ Scattering still explains some bug count variance

Marc Eaddy 52

DOS

Size

Bugs

.66

.90

.68

Page 53: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Side classesPowerful and disciplined class extension

Marc Eaddy 53

Powerful

•Combines subclasses, aspects, open classes, and refinements

•Unified subclass-like notation and semantics

•Multiple base classes can be extended simultaneously

Disciplined

•Extensions must be explicitly allowed

•Limits quantification

Page 54: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

The expression problem

□ Need to parse simple expression language

□ e.g., 3 + 4

□ Expressions: Literal, Add

□ Semantics: eval

□ Extensibility goals

□ Easily add new expressions

□ Easily add new semantics

□ Cannot do both easily

Marc Eaddy 54

P. Tarr, H. Ossher, W. Harrison, S. Sutton Jr., “N Degrees of Separation: Multi-Dimensional Separation of Concerns,” ICSE 1999.

M. Torgersen, “The Expression Problem Revisited,” ECOOP 2004.

Easy in OO

Easy in FP

Page 55: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Parser implementation in OOabstract class Expr {

abstract int eval();

}

class Add : Expr {

public Expr l, r;

public Add(Expr l, Expr r) { this.l = l; this.r = r; }

public int eval() { return l.eval() + r.eval(); }

}

Marc Eaddy 55

• New concern: Add printing semantics

– Concern is crosscutting!

Page 56: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Add printing using subclassing

abstract class PrintingExpr : Expr {

abstract void print();

}

class PrintingAdd : PrintingExpr, Add {

public void print() { Console.WriteLine(l + “+” + r); }

}

Marc Eaddy 56

• Invasive

• Inflexible

Page 57: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Printing the side class way

abstract class PrintingExpr + Expr {

abstract void print();

}

class PrintingAdd + PrintingExpr, Add {

public void print() { Console.WriteLine(l + “+” + r); }

}

Marc Eaddy 57

• Modularizes the printing concern

• Side class implicitly extends base class

• Clients (and other sub/side classes) oblivious

Page 58: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Caching result of eval()

□ Concern: Cache expression evaluation

□ Invalidate cache when expression changes

Marc Eaddy 58

Page 59: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Intertype declarations

interface IObserver {

void onChange();

}

class CachableExpr + Expr : IObserver {

protected IObserver obs = null;

protected int cache;protected bool isCacheValid = false;

void onChanged() {

isCacheValid = false;

if (obs != null) obs.onChanged();

}

}Marc Eaddy 59

Page 60: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Intertype declarations

interface IObserver {

void onChange();

}

class CachableExpr + Expr : IObserver {

protected IObserver obs = null;

protected int cache;protected bool isCacheValid = false;

void onChanged() {

isCacheValid = false;

if (obs != null) obs.onChanged();

}

}Marc Eaddy 60

Memberintertype

declarations

Interfaceintertype

declaration

Page 61: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Method chaining

class CachableAdd + Add {

public Add(Expr l, Expr r) {

base(l, r);

this.l.obs = this;

this.r.obs = this;

}

override public int eval() {

if (!isCacheValid) {

cache = base.eval();

isCacheValid = true;

}

return cache;

} Marc Eaddy 61

Page 62: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Method chaining

class CachableAdd + Add {

public Add(Expr l, Expr r) {

base(l, r);

this.l.obs = this;

this.r.obs = this;

}

override public int eval() {

if (!isCacheValid) {

cache = base.eval();

isCacheValid = true;

}

return cache;

} Marc Eaddy 62

Call ‘next’ delegate

Page 63: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Virtual fieldsoverride Expr l {

set {

base.l = value;

this.l.obs = this;

this.onChange();

}

}

override Expr r {

set {

base.r = value;

this.r.obs = this;

this.onChange();

}

}Marc Eaddy 63

Page 64: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Virtual fields

Marc Eaddy 64

Virtualfield

override

override Expr l {

set {

base.l = value;

this.l.obs = this;

this.onChange();

}

}

override Expr r {

set {

base.r = value;

this.r.obs = this;

this.onChange();

}

}

Page 65: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Metaprogramming

override Expr [$which = l | r] {

set {

base.$which = value;

this.$which.obs = this;

this.onChange();

}

}

Marc Eaddy 65

MetavariableLimited

quantification

Page 66: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

However, base class mustpermit extension

Marc Eaddy 66

class Add : Expr {

public virtual Expr l, r;

public Add(Expr l, Expr r) { this.l = l; this.r = r; }

public virtual int eval() { return l.eval() + r.eval(); }

}

Page 67: Overview - cs.columbia.edueaddy/FXPAL.pdf · .NET is language agnostic C#, but also JScript, Python, Perl, etc. High performance Compiled, not interpreted No glue code Edit-and-continue

Addresses issues of existing mechanisms

□ Subclasses□ Inflexible composition□ Only extend one base class□ Only extend instance methods□ Requires invasive changes in clients

□ Open classes/refinements/mixins□ Need for composition ordering□ Need for constructor and static member overriding

□ Aspects□ Lack of modular reasoning□ Poor integration with existing OO syntax and semantics□ Need for symmetric model□ Matching wrong join points

Marc Eaddy 67