Hyper/J George Fairbanks Objects and Aspects 12 November 2004 Harumph! Too cold! Too hot! 6 November 2015 Everything stinks!

Download Report

Transcript Hyper/J George Fairbanks Objects and Aspects 12 November 2004 Harumph! Too cold! Too hot! 6 November 2015 Everything stinks!

Hyper/J
George Fairbanks
Objects and Aspects
12 November 2004
Harumph!
Too cold!
Too hot!
6 November 2015
Everything
stinks!
2
Outline
•
History
•
Hyper/J
•
Discussion
•
•
•
•
•
•
•
•
Subjects
Multi-Dimensional Separation of Concerns
Artifact structure
Hyperspaces
Concerns
Hypermodules
Merging
Experience
6 November 2015
3
History: Subjects
•
Objects are good because
of polymorphism and
encapsulation
•
In a large team, different
programmers want to
extend the object to add
their functionality
•
How is a poor
programmer supposed to
anticipate all those
features?
6 November 2015
4
History: MDSoC
•
•
MDSoC= Multi-Dimensional Separation of Concerns
Meta, very meta
•
Hyperslice
•
“Tyranny of the dominant decomposition”
•
Tangling
•
Scattering
•
•
•
•
•
A set of modules where all code is for a given concern
“Declaratively complete” – not a simple partition
The primary structure of a system
One method has code for many concerns
Code for one concern in many methods
6 November 2015
5
Hyper/J
•
An “instance of MDSoC” that
•
Note: No Base/Aspect duality like in AspectJ
•
Various composition rules can be defined
•
•
enables the definition of Java concerns (hyperslices)
merges the concerns into a complete Java program
6 November 2015
6
Hyper/J Artifact Structure
•
… and processing
Hyperspace
Hyperslice
Hyperslice
Hyperslice
Hyperslice
Hyperslice
Hyper/J
Hypermodule
Hyperslice
Hyperslice
Merge
Rule
Hyperslice
Hyperslice
javac
6 November 2015
7
Hyperspace
hyperspace
composable
composable
composable
•
DemoHyperspace
class demo.ObjectDimension.*;
class demo.StyleChecker.*;
class demo.Observer.*;
The Hyperspace definition is equivalent to defining
the files in a project
6 November 2015
8
Hyperslice
package demo.ObjectDimension : Feature.Kernel
operation check : Feature.Check
operation display : Feature.Display
operation eval : Feature.Eval
operation check_process : Feature.Check
operation display_process : Feature.Display
operation eval_process : Feature.Eval
operation process : Feature.None
package demo.StyleChecker : Feature.StyleChecker
package demo.Observer : Feature.Logging
•
Maps source code to concerns (features / aspects /
hyperslices)
6 November 2015
9
Hypermodule
hypermodule DemoSEE
hyperslices:
Feature.Kernel, Feature.Check, Feature.Display,
Feature.Eval, Feature.StyleChecker, Feature.Logging;
relationships:
mergeByName;
equate operation Feature.Kernel.process, Feature.Check.check_process,
Feature.Display.display_process, Feature.Eval.eval_process;
bracket "*"."{~_,~<}*"
before Feature.Logging.LoggedClass._beforeInvoke( $ClassName, $OperationName ),
after Feature.Logging.LoggedClass._afterInvoke( $ClassName, $OperationName );
set summary function
for action DemoSEE.BinaryOperator.check
to action DemoSEE.Expression.summarizeCheck;
end hypermodule;
•
•
Defines the composition of the concerns
Detail on next slide
6 November 2015
10
Merging (Weaving)
•
What matches?
•
Equate
•
Bracket
•
Set summary function
•
•
•
•
mergeByName, nonCorrespondingMerge,
overrideByName
different names but really the same
Methods should be preceded/followed by others
What is the return value of a composed function?
6 November 2015
11
Simple Example
•
In foo.java
public class Foo {
public void sayHi() {
System.out.println(“Hi”);
}
}
•
In bar.java
public class Bar {
public void sayBye() {
System.out.println(“Bye”);
}
}
6 November 2015
•
In demo.opt config file
-hyperspace
hyperspace demo
composable class Foo;
composable class Bar;
-concerns
class Foo : Feature.hi
class Bar : Feature.bye
-hypermodules
hypermodule DemoHM
hyperslices: Feature.hi, Feature.bye;
relationships:
mergeByName;
equate operation Feature.hi.sayHi,
Feature.bye.sayBye
into greet;
merge class Feature.hi.Foo, Feature.bye.Bar;
end hypermodule;
12
Hyper/J Experience
•
Results from Murphy et al.
•
Results from Chavez et al.
•
•
•
•
•
•
•
•
Compared AspectJ, Hyper/J, LSOC tools
Still need to decide structures in advance
Concerns should not be tangled in a method
Refactoring tools needed
Wrote an AspectJ program
Restructured it for Hyper/J
Hyper/J may be less readable
Hyper/J externalized composition rules helpful vs.
AspectJ’s internal dominates rule
6 November 2015
13
Tooling: CME
•
CME= Concern Manipulation Environment
•
I would have a live demo of CME here but all I can
seem to do is hang it. It is version 0.1.2.
6 November 2015
14
Discussion
•
Comparison with AspectJ
•
•
No “base/aspect dichotomy”, but “Kernel” hyperslice
appears commonly
Within-method concerns: which is better?
•
When is program evolution easier, harder?
•
What are the programmer’s benefits, burdens?
•
If you owned a company, how would you decide
whether or not to use Hyper/J?
6 November 2015
15