150 likes | 467 Views
Hyper/J. George Fairbanks Objects and Aspects 12 November 2004. Harumph!. Too cold!. Too hot!. Everything stinks!. Outline. History Subjects Multi-Dimensional Separation of Concerns Hyper/J Artifact structure Hyperspaces Concerns Hypermodules Merging Experience Discussion.
E N D
Hyper/J George Fairbanks Objects and Aspects 12 November 2004
Harumph! Too cold! Too hot! Everything stinks!
Outline • History • Subjects • Multi-Dimensional Separation of Concerns • Hyper/J • Artifact structure • Hyperspaces • Concerns • Hypermodules • Merging • Experience • Discussion
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?
History: MDSoC • MDSoC= Multi-Dimensional Separation of Concerns • Meta, very meta • Hyperslice • A set of modules where all code is for a given concern • “Declaratively complete” – not a simple partition • “Tyranny of the dominant decomposition” • The primary structure of a system • Tangling • One method has code for many concerns • Scattering • Code for one concern in many methods
Hyper/J • An “instance of MDSoC” that • enables the definition of Java concerns (hyperslices) • merges the concerns into a complete Java program • Note: No Base/Aspect duality like in AspectJ • Various composition rules can be defined
Hyperspace Hyperslice Merge Rule Hypermodule Hyperslice Hyperslice Hyperslice Hyperslice Hyperslice Hyperslice Hyperslice Hyperslice Hyper/J Artifact Structure • … and processing Hyper/J javac
Hyperspace hyperspace DemoHyperspace composable class demo.ObjectDimension.*; composable class demo.StyleChecker.*; composable class demo.Observer.*; • The Hyperspace definition is equivalent to defining the files in a project
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)
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
Merging (Weaving) • What matches? • mergeByName, nonCorrespondingMerge, overrideByName • Equate • different names but really the same • Bracket • Methods should be preceded/followed by others • Set summary function • What is the return value of a composed function?
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”); } } 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; Simple Example
Hyper/J Experience • Results from Murphy 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 • Results from Chavez et al. • 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
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.
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?