Moderne Softwareentwicklungsmethoden Workshop Moderne Softwareentwicklungs Methoden Teil 1






































































































































- Slides: 134
Moderne Softwareentwicklungsmethoden Workshop: Moderne Softwareentwicklungs. Methoden Teil 1: AOP, MDSOC, GP, IP Teil 2: e. Xtreme Programming Markus Völter markus. voelter@mathema. de Michael Wiedeking michael. wiedeking@mathema. de Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Contents (I) <The big picture <Product Line Engineering <Variability Analysis <How AOP, GP, IP and MDSOC can help <Generative Programming <Principles <Compile-time Metaprogramming (using templates) <Jenerator – Generative Programming for Java <Other GP tools <Aspect-Oriented Programming <Principles <Patterns for AOP <Aspect. J <Sally <Jenerator and AOP Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Contents (II) <Multidimensional Separation of Concerns <Problem revisited: Multidimensional Variability <Example introduced: SEE <Hyper/J concepts <Example continued <Intentional Programming <Background <Basic Concepts <IP System Architecture <Active Source <Stunning Features <Thanks <Resources Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden The big picture Product Line Engineering Variability Analysis How AOP, GP, IP and MDSOC can help Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Common Roots: Product Line Engineering <Instead of developing one single system, development focuses on a family of related systems. Reasons: <different target platforms (operating system, middleware) <different quality of service (Qo. S) requirements, <potential for future growth <Systems are built from product-specific parts and reusable part: the common platform <Creation of concrete systems should be done with the help of a (semi-)automatic process <industrialized production of software <„build software like they build cars“ Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Common Roots: Product Line Engineering Software Family Instead of developing onebysingle as defined Parnassystem, in 1976: development < focuses on a family of related systems. Reasons: We consider a set of programs to <different target platforms (operating system, constitute a family whenever it is middleware) worthwhile to study programs from the set by first studying the common <different quality of service (Qo. S) requirements, properties of the set and then determining <potential for future growth the special properties of the individual family members. <Creation of concrete systems should be done with the help of a (semi-)automatic process <industrialized production of software <„build software like they build cars“ Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Product Line Engineering: Process <Domain Scoping <Variability Analysis <Domain Structuring <Define common architecture <Define Production Plan <Define Building Blocks <Components <DSLs & Generators <Production Process Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Product Line Engineering: Process <AOP, IP, GP & MDSOC are located here. But first. . . Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Domain Analysis <Goal: A domain model <Scoping defines, what is part of the domain, and what is not (defines the range of possible products) <Example: GQM (Goal Question Metric) <A common vocabulary defines the terms in which the domain can be described <The commonalities and the differences between different products in the domain have to be defined Variability Analysis Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Variability Analysis < Variability analysis discovers the variable and fixed parts of a product in a domain. Parts can be <structural, or <behavioral (functional) <non-functional (technical) < To define variable aspects, we need to have a commonality base: something fixed < There are two kinds of variability: <positive variability: add something (optional) <negative variability: removes something (essential) <Positive variability leaves the concept intact, while netative variability does not. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Domain Analysis: Feature Modelling < Feature Modelling is more abstract than OO analysis and design because it does not prescribe the realization of features < A feature model describes the (sub-)features of a concept <Subfeatures can be <Mandatory <Optional <Alternative <N of M < A feature model can be multi-dimensional < A graphical notation exists: feature diagrams Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Feature Diagram: Aircraft example < Example products: <An aircraft with a low wing, piston engine and made of metal, wood and cloth: Robin DR-400 <An aircraft with shoulder wing, no engine and made of plastic: ASW-27 <An aircraft with low wing, jet engine(s) and made of metal: Airbus A 320 Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden More features of feature diagrams <They can contain constraints on the combinations of features <They can define „names“ for specific combinations of features; feature groups <Features can be open: additional subfeatures can be added <Features can be incomplete: the subfeatures are not yet defined <Multiplicity of subfeatures can be added Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Exercise 1: Feature Models Describe a feature model for a specific concept using a feature diagram. You may use a suitable editor for that purpose. Possible concepts: Personal Computer, Vehicle, JVM, curriculum, list (software) Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Binding Times <A feature diagram defines the common and variable aspects of a system. It has to be defined, when the variable aspects are fixed for a particular product. This is called binding time. <Usually, binding time has consequences on <flexibility <performance <code size <type safety <and: on the technique used to implement the variable aspect Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Typical Binding Times <source time: manual programming, template parameters <compile time: function overloading, precompiler, template evaluation <link time: DLLs, class loading <run time: virtual functions, inheritance & polymorphism, factory-based instance creation, delegation <deployment/configuration time: component deployment (impl. for an interface), environment variables Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Binding Times and consequences (at runtime) Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Exercise 2: Binding Times Depending on the programming language used, there are different techniques how the binding times can be realised. Some may even be impossible. Select one of the following languages and describe the possible realization of the binding times, as well as potential advantages and drawbacks: Languages: C++, Java, Eiffel, Ada, Smalltalk, Perl Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Source Time binding <Source time binding is tedious and error prone, because it has to be programmed manually. <However, it has significant advantages: High performance, low code size <Of course, some flexibility is sacrificed <To make source time binding more efficiently usable, generative programming can be used. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Multi-Dimensional Variability <A software system, and a family of systems in a domain, is usually decomposed, or structured using one dimension only. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden What is multi-dimensional variability <Multi-Dimensional means: <The variability aspects can vary independently <They cannot be decomposed in one hierarchy <Typically, the result is many possible combinations (permutations) of the dimensions Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Multi-Dimensional Variability <What, if an certain feature cannot be decomposed along this same dimension? Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Multi-Dimensional Variability: Apache Example <Logging <Session Expiration Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Multi-Dimensional Variability <Things that are tangled all through the primary decomposition structure are called cross-cutting concerns. <have a well-defined purpose <have a non-obvious structure <Thus, Aspects are a way to separate concerns. It <catches cross-cutting concerns <in a single syntactic entity Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden AOP generalized <AOP uses one primary decomposition structure (classes) and several additional aspects that crosscut this structure. <New aspects can be added after the system is designed <A more generalized approach to realizing multi- dimensional variability is Multi-Dimensional Separation of Concerns (MDSOC): <There is no primary decomposition structure, all dimensions are treated equal. <each concerns is specified in its decomposition structure, <and combined with other concerns in a second step. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden MDSOC-Techniques <Help to modularize the different concerns (dimensions) that arise from the feature model of a product family. <Examples of MDSOC are <adaptive programming <aspect oriented programming (AOP) <composition filters <role-modelling <subject-oriented programming (SOP) <hyperspaces Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Specifying products <A product in a software family can be specified by combining the features in a specific, legal way. <Such a specification can become quite complex, because <Several different techniques might be used <Constraints on the feature model have to be enforced <It might be very low-level (programming-language dependent) <To overcome these problems, Domain-Specific Languages can be used. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Domain-Specific Languages (DSLs) <Allow to specify systems (or products of a family) in terms (vocabulary) of the software family. A higher level of expressiveness is thus reached. <Thus, Intentional Programming can be seen as a construction kit for multilevel-DSLs: <represents general and domain specific abstractions as intentions <provides an extensible environment that allows to load (domain-specific) extensions <represents source code as active entities <extensions can affect the complete environment; the editor, compiler, debugger, version control, . . . Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Relations among the mentioned techniques Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
? Moderne Softwareentwicklungsmethoden Domain Engineering: Can it be used today? <It has been in use by several institutions, e. g. SEI, Mobile Phone manufacturers <Feature models and diagrams are useable today and very helpful, so is variability analysis. <Frameworks are a way to realize product lines, as well as components. Both are in use today. <Thinking about binding times other than runtime is also very useful. Ok, this is not really part of the tutorial, but anyway Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Generative Programming Principles Compile-time Metaprogramming Jenerator – Generative Programming for Java Other GP tools Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Generative Programming (GP) <Industrialized production of products from a product line/system family <Take care of the different binding times by using appropriate tools <For example code generation to take care of source time variability, <Reflection at runtime <Optimization wherever possible and useful <Improve performance by remove runtime decisions <Reduce code size by only including the really needed parts Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden GP Elements < Generative Domain Model consists of the following elements <A way to specify products (family members) <Implementation components from which these members can be assembled <And configuration knowledge, which maps between the spec of a member and its implementation < The terms problem space and solution space are used for specification and implementation components Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Product Specification <Product specification is usually done by using <feature models (in textual or graphical notation) <declarative languages (DSLs) <regular programming with generators Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Configuration Knowledge <Constraints on the configuration space, i. e. legal and illegal product configurations <Defaults configurations (default components and dependencies) <Feature mapping (which implementation components satisfy which feature) <Optimizations (optimzing for performance, or for code size, or for safety) Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Implementation Components <Active Libraries (such as template libraries that generate code) <DSLs and their mappings <code generators <code transformers Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden GP Example: C++ Template Metaprogramming < Also called compile-time metaprogramming, because metaprograms „run“ while the program is compiled < Uses the features of C++ template instantiation < Programming style is „functional“ and operates on types < Note that some awkward constructs are required, <because C++ templates were not originally intended for this purpose <and many generally unknown and non-trivial features of the standard are used. < Error reporting is usually clumsy Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden GP Example: C++ Template Metaprogramming struct Simple. Bounds. Checker; template<class Element. Type, class Bounds. Checker=Simple. Bounds. Checker> class Vector { public: //. . . Element. Type& at(const int& i) { Bounds. Checker: : check. Bounds(i, length); //. . . } //. . . }; struct Out. Of. Bounds {}; struct Simple. Bounds. Checker { static void check. Bounds(const int& i, const int& length) { if(i<0 || i>=length) throw Out. Of. Bounds(); } }; Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG struct Empty. Bounds. Checker { static void check. Bounds(const int& i, const int& length) { } }; //. . . int main() { Vector<int> v 1; //v 1 uses Simple. Bounds. Checker Vector<int, Empty. Bounds. Checker> v 2; //v 2 uses Empty. Bounds. Checker return 0; }
Moderne Softwareentwicklungsmethoden GP Example: C++ Template Metaprogramming struct Simple. Bounds. Checker; template<class Element. Type, class Bounds. Checker=Simple. Bounds. Checker> class Vector { public: //. . . Element. Type& at(const int& i) { Bounds. Checker: : check. Bounds(i, length); //. . . } //. . . }; struct Empty. Bounds. Checker { static void check. Bounds(const int& i, const int& length) { } }; <„combines“ the classes at compile time //. . . <Creates only thoseint main() versions that are really used { Vector<int> v 1; //v 1 uses Simple. Bounds. Checker Vector<int, Empty. Bounds. Checker> v 2; //v 2 uses Empty. Bounds. Checker return 0; } <Inlining is used to improve runtime struct Out. Of. Bounds {}; performance (or reduce code size) struct Simple. Bounds. Checker { static void check. Bounds(const int& i, const int& length) { if(i<0 || i>=length) throw Out. Of. Bounds(); } }; <Calls to empty operations are eliminated Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Template Metaprogramming: IF <A static if can be used to check boolean conditions on types at compile time. #include <iostream> using namespace std; template<bool condition, class Then, class Else> struct IF { typedef Then RET; }; //specialization for condition==false template<class Then, class Else> struct IF<false, Then, Else> { typedef Else RET; }; void main() { cout << "sizeof(short) = " << sizeof(short) << endl << "sizeof(int) = " << sizeof(int) << endl << "sizeof(IF<(1+2>4), short, int>: : RET) = " << sizeof(IF<(1+2>4), short, int>: : RET) << endl; IF<(1+2>4), short, int>: : RET i; //the type of i is int! } Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Compile Time Factorial <Statically calculates the factorial of an int at compile time! <At runtime, the result is a constant! #include <iostream> using namespace std; #include ". . /meta. h" using namespace meta; struct Stop { enum { RET = 1 }; }; template<int n> struct Factorial { typedef IF<n==0, Stop, Factorial<n-1> >: : RET Previous. Factorial; enum { RET = (n==0) ? Previous. Factorial: : RET : Previous. Factorial: : RET * n }; }; void main() { cout << Factorial<3>: : RET << endl; } Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Other compile time functions < Static versions of <switch, <while, <do-while <for <etc. . . < It has been shown that the C++ template facility can be used as a full-blown functional programming language. Its data are the types and constant integral values of the C++ language. < In generative programming, these and other constructs are used to select code to be included in the final program. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Exercise 3: Template Metaprogramming Below you can find a static version of switch. Try(!) to explain how it works. #include <iostream> using namespace std; // SWITCH<> template<int tag, class Case> class SWITCH #include ". . /meta. h" { typedef typename Case: : Next. Case; using meta: : IF; enum { const int DEFAULT = ~(~0 u >> 1); case. Tag = Case: : tag, //initialize with smallest found = (case. Tag == tag || case. Tag == DEFAULT) }; struct Nil. Case {}; public: template <int tag_, class Type_, typedef IF<found, class Next_ = Nil. Case> typename Case: : Type, struct CASE typename SWITCH<tag, Next. Case>: : RET { enum { tag = tag_ }; >: : RET; typedef Type_ Type; }; typedef Next_ Next; }; Moderne Softwareentwicklungsmethoden template<int tag> class SWITCH<tag, Nil. Case> {public: typedef Nil. Case RET; }; copyright © 2001, MATHEMA AG // test struct A {static void exec(){ cout << "A" << endl; } }; struct B {static void exec(){ cout << "B" << endl; } }; struct D {static void exec(){ cout << "Def" << endl; }}; void main() { SWITCH<(1+1 -2), CASE<1, A, CASE<2, B, CASE<DEFAULT, D > > : : RET: : exec(); }
Moderne Softwareentwicklungsmethoden Why use template metaprogramming <Allows you to „modify“ or adapt your program at compile time to achieve <Performance Optimizations, <Inlining, <Loop unrolling <Size-specific adaptions <Type-specific adaptions <Memory Optimizations <Code size Optimizations <Keep out all the code that is not necessary <Use code optimized for specific cases <Other stuff <Adapt Interfaces at compile time <Impress and scare other people Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Example: Generic Container Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Example: Generic Container template<class Generator> class Ptr. List { public: //make Config available as a member typedef typename Generator: : Config; private: typedef typename Config: : Element. Type; typedef typename Config: : Set. Head. Element. Type; typedef typename Config: : Return. Type; typedef typename Config: : Destroyer; typedef typename Config: : Type. Checker; typedef typename Config: : Copier; Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG public: Ptr. List(Set. Head. Element. Type& h, Return. Type *t = 0) : head_(0), tail_(t) { set. Head(h); } ~Ptr. List() { Destroyer: : destroy(head_); } void set. Head(Set. Head. Element. Type& h) { Type. Checker: : check(h); head_ = Copier: : copy(h); } Element. Type& head() { return *head_; } void set. Tail(Return. Type *t) { tail_ = t; } Return. Type *tail() const { return tail_; } private: Element. Type* head_; Return. Type *tail_; };
Moderne Softwareentwicklungsmethoden Example: Generic Container template<class Generator> class Ptr. List { public: //make Config available as a member typedef typename Generator: : Config; public: Ptr. List(Set. Head. Element. Type& h, Return. Type *t = 0) : head_(0), tail_(t) { set. Head(h); } <specific specialized templated classes exist for Copier, Type. Checker and Destroyer (kind ~Ptr. List() { of static subclassing) Destroyer: : destroy(head_); private: typedef typename Config: : Element. Type; typedef typename Config: : Set. Head. Element. Type; typedef typename Config: : Return. Type; } <Config serves as void set. Head(Set. Head. Element. Type& h) { the configuration Type. Checker: : check(h); repository and defines, which of them is head_ = Copier: : copy(h); used in a particular } generation typedef typename Config: : Destroyer; typedef typename Config: : Type. Checker; typedef typename Config: : Copier; Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG Element. Type& head() { return *head_; } void set. Tail(Return. Type *t) { tail_ = t; } Return. Type *tail() const { return tail_; } private: Element. Type* head_; Return. Type *tail_; };
Moderne Softwareentwicklungsmethoden Example: Generic Container <Config serves as the configuration repository for a specific List instantiation struct Ref. Poly. Person. List. Config { typedef Person typedef Element. Type typedef Empty. Destroyer<Element. Type> typedef Empty. Type. Checker<Element. Type> typedef Empty. Copier<Element. Type> typedef Ptr. List<Ref. Poly. Person. List. Config> } Element. Type; Set. Head. Element. Type; Destroyer; Type. Checker; Copier; Return. Type; // use it! Typedef Ref. Poly. Person. List. Config: : Return. Type Person. List; Person. List list = new Person. List(); Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Example: Generic Container < Last step: A Generator that takes a config structure and returns the generated product. < It uses enums, static IFs and static SWITCHes heavily. < Provides useful defaults < Usage example: LIST_GEN< Person, ext_ref, poly >: : RET some. List; Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Example: Generative Programming in Java < Java provides no templates. Template metaprogramming thus cannot work! < Also, GJ or Java 1. 5 templates or Ada can‘t do it, because they are implemented differently. < One approach is Jenerator, a code generation framework in and for Java. < It is implemented by MATHEMA and used in several projects <EJB generation <Component Container generation <. . . Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Example: Hello Jenerator public class Hello. Jenerator { public Hello. Jenerator() { CClass created. Class = new CClass( “jenerator", "Hello. World" ); CMethod main. Method = new CMethod( CVisibility. PUBLIC, CType. VOID, "main" ); main. Method. add. Parameter( new CParameter( CType. user( "String[]" ), "args" ) ); main. Method. add. To. Body( new Class. Instantiation( created. Class. get. Name(), "app", true ) ); CConstructor cons = new CConstructor( CVisibility. PUBLIC ); cons. add. To. Body( new CCode( "System. out. println("Hello World!"); " ) ); created. Class. add. Constructor( cons ); created. Class. add. Method( main. Method ); new Code. Generator(). create. Code( created. Class ); } } Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Jenerator Guiding Principle <Every interesting part of the AST can be modelled explicitly Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Jenerator: Principles for extension – building generative components <Jenerator applies the usual OO concepts on the generator level: <Subclassing: By subclassing generator classes, higher -level, domain specific generators can be created. <Parametrization: By parametrizing the generator classes, the behaviour of a generator can be easily controlled. <Delegation: Generator classes can use each other, creating more complex results. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Exercise 4: Jenerator You have seen the „Hello World“ program for Jenerator. It creates a CMethod object and prints out hello world. Try to outline how a CMain. Method could look like. It should contain the typical signature of main() and allow the programmer to add arbitrary code to the body of the operation. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Jenerator: More Advanced Techniques: Macros <A macro is an entity that modifies a CClass. <Example: Java. Bean properties class Some. Class { private String id; public void set. Id( String _id ) { id = _id; } public String get. Id() { return id; } } new Property( "name", CType. STRING ). execute( created. Class ); <can also operate on Class. Groups (see EJB generation) Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Jenerator Examples: Interceptor proxy <Goal: <For each class, a Proxy should be generated <Proxy allows to insert Interceptors to the invocation chain <Good performance <Must work for any class!! <Implementation alternatives: <Java‘s Proxy API can do that dynamically, but with significant runtime overhead. <Jenerator does it in a generative fashion, i. e. almost no overhead. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Jenerator Examples: Interceptor proxy <Goal: Be able to attach Interceptors to any object public class Test { public void add. Interceptors( Interceptable ic ) { ic. add. Interceptor( new Non. Null. Interceptor() ); } public Test() { Test. Generated tg = new Test. Generated(); tg = new Test. Generated. Interceptor( tg ); add. Interceptors( (Interceptable)tg ); tg. test 2(); tg. test 3(null); } public static void main( String[] args ) { new Test(); } } Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Jenerator Examples: Interceptor proxy <Some interfaces are required public abstract class Dynamic. Interceptor { public abstract void pre. Invoke( Object target, String op. Name, Object[] params, String[] param. Names ) throws Stop; } public interface Interceptable { void add. Interceptor( Dynamic. Interceptor interceptor ); } <Example interceptor: Throws exception in case of null argument public class Non. Null. Interceptor extends Dynamic. Interceptor { public void pre. Invoke( Object target, String op. Name, Object[] params, String[] param. Names ) throws Stop { for ( int i=0; i<params. length; i++ ) { if ( params[i] == null ) throw new Stop( "null value caught: "+param. Names[i] ); } } } Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Jenerator Examples: Interceptor proxy <Once the generators are implemented, their use is fairly simple (their implementation isn‘t hard either, it‘s just too much code to show here ) CClass test. Class = new CClass( "generated", "Test. Generated" ); CMethod test. Method = new CMethod( CVisibility. PUBLIC, CType. INT, "test 2" ); test. Method. add. Child( new CSys. Out( "Test 2" ) ); test. Method. add. Child( new CCode( "return 0; " ) ); test. Class. add. Method( test. Method ); CMethod am = new CMethod( CVisibility. PUBLIC, CType. VOID, "test 3" ); am. add. Parameter( new CParameter( CType. OBJECT, "a. Param" ) ); am. add. Child( new CSys. Out( "Test 3" ) ); test. Class. add. Method( am ); am = new CMethod( CVisibility. PUBLIC, CType. VOID, "test 6" ); am. add. Parameter( new CParameter( CType. INT, "a. Param" ) ); test. Class. add. Method( am ); gen = new Interceptor. Proxy( test. Class ); CClass proxy 2 = generate. Proxy( null ); Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Exercise 5: Jenerator II The example just seen creates a proxy for an aribitrary class and provides an interface to plug-in interceptors at runtime (runtime of the generated program). This still has some performance overhead, because at runtime the system has to iterate over the interceptors and do quite a lot of method invocations. . . Try to optimize this by inlining the interceptors calls directly at the call sites. Of course, the configuration of which interceptors to use will have to happen at generation time. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Other GP examples: COMPOST <COMPOST is a software composition system to <engineer <reengineer <evolve software <by program transformations. <COMPOST supports invasive composition <COMPOST's architectural language is Java <Technically, COMPOST is a set of tools cooperating to attack the problems described above. <COMPOST is still a research tool. <URL: i 44 s 11. info. uni-karlsruhe. de/~compost/ Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Other GP examples: COMPOST (II) < COMPOST Recorder. It provides <Parsing and unparsing of Java sources <Simple preprocessors, simple code generators, source code beautification tools <Name and type analysis for Java programs <Software visualization tools, software metrics, Lint-like semantic problem detection tools, design problem detection tools (antipatterns), cross-referencing tools < Transformation of Java sources <Preprocessors for language extensions, semantic macros, aspect weavers, source code obfuscation tools, compilers <Incremental analysis and transformation of Java sources <Source code optimization, refactoring tool, software migration programs (Smart Patches), design pattern, clichés and idiom synthesis, architectural connector synthesis, adaptive programming environments, invasive software composition Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Other GP examples: FUUT-je <FUUT-je (The Fantastic, Unique UML Fool for the Java Environment) <Generates code from (simple) UML models <Uses a mix of Java code and UML for code generation. <Has been used by the author to generate code for IBM‘s San Francisco <URL: www. bronstee. com/spider/fuutoverview. html Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Other GP examples: FUUT-je (II) <Rule> <Target>Attributes</Target> <Condition> scope = public </Condition> /** * Gets the #<attribute. name># property */ public #<type># get#<u. name>#() { return #<name>#; } </Rule> <Target>Attributes</Target> <Condition> scope = public </Condition> /** * Sets the #<name># property (#<type>#) value. */ public void set#<u. name>#(#<type># p#<u. name>#) { #<name># = p#<u. name>#; } </Rule> Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG /**Gets the description property */ public String get. Description() { return description; } /** Sets the owner property */ public void set. Owner(String p. Owner) { owner = p. Owner; }
Moderne Softwareentwicklungsmethoden Other GP examples: MDA (ok, to some extent) <MDA is OMG‘s new initiative <Generate application code from plattform independent domain models (UML) using welldefined rules and transformations. <URL: www. omg. org/mda Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
? Moderne Softwareentwicklungsmethoden GP: Can it be used today? <Generating code is not completely new and is used today. <Template metaprogramming is used increasingly in C++, for example in the BOOST library. <Several approach exist and can be used, others are still subject to research. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Aspect Oriented Programming Principles Patterns for AOP Aspect. J Sally Jenerator and AOP Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden AOP principles <AOP is a „mind set“ and can be used with ordinary programming languages. <Key point is Separation of Concerns. <Some design patterns can help to realize AOP concepts in normal languages. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Exercise 6: Aspects Join up in groups, agree on a well-known kind of application and try to identify some typical aspects, things, that are usually scattered all over the place. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden DIY-AOP: Decorator <Es kann transparent zu einem Objekt neue Funktionalität hinzugefügt werden, <z. B. pre/post operations Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden DIY-AOP: Decorator Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden DIY-AOP: Proxy <Proxies können Methodenaufrufe „abfangen“ und deren Semantik verändern <Beispiel: Remote Proxy Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden DIY-AOP: Factory <Factories abstrahieren den Erstellungsprozess von Objektes <Damit können z. B. Proxies, Singletons oder Decorators erstellt werden Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Exercise 7: Aspects and Patterns You want to provide a Logging aspect for method invocations and for object creation for your applications. It should be possible to run the application with or without logging enabled. Use the above mentioned patterns to implement these requirements as separate entities. Discuss advantages and drawbacks of implementing aspects this way. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden AOP compared to Frameworks <Frameworks require an identification of hot spots as part of its design. <AOP allows you to inject aspects into a completely designed system without prior planning. <Thus, many of the goals of frameworks can also be realized by AOP, of course with a different approach. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden AOP tools: Aspect. J <Aspect. J is an AOP extension to Java. <It allows to define aspects as separate source entities <They are woven together with the regular code before compilation. <The result of the weaving process is normal Java source. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Java and Aspects in Aspect. J < Join points <connect normal Java programs and Aspects <“points in the execution” of Java programs < 4 small additions to Java <Pointcuts pick out join points and values at those points <Advices define additional action to take at join points in a pointcut <Introductions additional fields/methods/constructors to classes <Aspects are crosscutting types comprised of advice, introduction, field, constructor and method declarations Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Typical Join Points < Usually, join points are concerned with the message exchange between objects, i. e. method calls. < several kinds of join points <method & constructor call join points <method & constructor execution join points <field get & set join points <exception handler execution join points <static & dynamic initialization join points Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Example: Figures in Drawing application <Goal: Display has to be updated when figures move. class Line implements Figure. Element{ private Point p 1, p 2; Point get. P 1() { return p 1; } Point get. P 2() { return p 2; } void set. P 1(Point p 1) { this. p 1 = p 1; } void set. P 2(Point p 2) { this. p 2 = p 2; } } class Point implements Figure. Element { private int x = 0, y = 0; int get. X() { return x; } int get. Y() { return y; } void set. X(int x) { this. x = x; } void set. Y(int y) { this. y = y; } } Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Example without aspects class Line { private Point p 1, p 2; Point get. P 1() { return p 1; } Point get. P 2() { return p 2; } void set. P 1(Point p 1) { this. p 1 = p 1; Move. Tracking. set. Flag(); } void set. P 2(Point p 2) { this. p 2 = p 2; Move. Tracking. set. Flag(); } } <Invasive change required because it is a cross-cutting concern. Moderne Softwareentwicklungsmethoden class Move. Tracking { private static boolean flag = false; public static void set. Flag() { flag = true; } public static boolean test. And. Clear() { boolean result = flag; flag = false; return result; } } copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Example: Figures in Drawing application <each time a Line receives a void set. P 1(Point) or void set. P 2(Point) method call <The following pointcut captures this situation: pointcut move(): call(void Line. set. P 1(Point)) || call(void Line. set. P 2(Point)); <We want to „step in“ after the point has been updated: Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Aspect declaration that does just that aspect Move. Tracking { private boolean flag = false; public boolean test. And. Clear() { boolean result = flag; flag = false; return result; } pointcut move(): call(void Line. set. P 1(Point)) || call(void Line. set. P 2(Point)); after() returning: move() { flag = true; // and update display } } Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Aspect declaration that does just that <Advising several classes is also possible: public boolean test. And. Clear() { pointcut move(): boolean result = flag; call(void Line. set. P 1(Point)) || flag = false; call(void Line. set. P 2(Point)) || return result; call(void Point. set. X(int)) || } call(void Point. set. Y(int)); pointcut move(): call(void Line. set. P 1(Point)) || call(void Line. set. P 2(Point)); after() returning: move() { flag = true; // and update display } } Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Combining aspects and normal code <Advising several classes is also possible: ajc Point. java Line. java Move. Tracking. java <Or: <Result is ordinary Java class files. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Aspect. J features <Join Points <method & cons calls & executions <field gets and sets <exception handler executions <intializations <Aspects <pertarget <perthis <percflowbelow Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG < Pointcuts <call <execution <handler <get set <initialization <this target <withincode <cflowbelow < Advice <before <after <around
Moderne Softwareentwicklungsmethoden Exercise 8: Aspects and Aspect. J Again: You want to provide a Logging aspect for method invocations and for object creation for your applications. It should be possible to run the application with or without logging enabled. This time, use Aspect. J to implement these requirements as separate entities. Discuss advantages and drawbacks of implementing aspects this way. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Sally – an object model for aspect languages <Join Points are declared by 4 -tuple joinpoint j 1 {B, void, method. B, null} <A pointcut is an interaction between two join points. joinpoint j 1 {B, void, method. B, null} joinpoint j 2 {C, int, method. C, null} pointcut pc {j 1, j 2} <Advices are special methods. public void before. PC() before pc { // insert code here } Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Sally (II) <Aspects are declared like classes, with additionally join point, pointcut and advice method declarations. aspect Some. Aspect { joinpoint j 1 {B, void, method. B, null} joinpoint j 2 {C, int, method. C, null} pointcut pc {j 1, j 2} public void before. PC() before pc { // insert code here } } <Aspects can be abstract (with abstract join points) and can be extended by inheritance. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Exercise 9: Different Aspect Languages Compare the way Sally and Aspect. J implement aspects. What are the commonalities, the differences? Which approach do you like better? Which is more versatile? Can you think of other ways how aspects can be implemented? Consider Templates in C++, or Java‘s Dynamic Proxies Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Jenerator: Aspects <Jenerator also supports aspect. <In Jenerator, an aspect consists of <introduce() <joint. Point. Class() <applies. To() <apply() Moderne Softwareentwicklungsmethoden package de. mathema. jenerator. paper; // imports… public class Log. Object. Creation. Aspect extends Aspect { public Class join. Point. Class() { return Class. Instantiation. class; } public void apply( Code. Snippet cs ) { Class. Instantiation inst = (Class. Instantiation)cs; Code. Container container = inst. parent(); CMethod m = (CMethod)inst. parent( CMethod. class ); CClass c = (CClass)inst. parent( CClass. class ); String log = "System. out. println( //logmessage container. add. Child. Before( new CCode( log ), cs ); } } copyright © 2001, MATHEMA AG
? Moderne Softwareentwicklungsmethoden AOP: Can it be used today? <The concept of separating out certain aspects into separate units is certainly worthwhile. <Using patterns, or native language mechanisms to represent aspects works fine. <Aspect. J can be used in certain environments, however, for example debugging support is limited; it is not so simple to use it together with e. g. EJB. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Multidimensional Separation of Concerns (MDSOC) Problem revisited: Multidimensional Variability Example introduced: SEE Hyper/J concepts Example continued Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden MDSOC Basics < Goals are somewhat similar to AOP, only a bit more general. < Separation of concerns is <an approach to decomposing software into modules, <each of which deals with, and encapsulates, a particular area of interest, called a concern. < Examples of concerns are <functions, data types or classes, <features (e. g. , "persistence, „ "print, " or "concurrency control"), <variants, <and roles. < Object-oriented languages permit decomposition only by class. (Tyranny of the dominant decomposition). Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Multi-Dimensional Variability <What, if an certain feature cannot be decomposed along this same dimension? Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Exercise 10: Decomposition Tyranny The Tyranny of the dominant decomposition states that a programming paradigm usually only allows one way, the dominant way, of decomposing a system. You have seen this for procedural and object-oriented languages. What are the dominant decompositions in other programming languages, and which techniques are available to break this tyranny? Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden MDSOC Basics (II) <It is thus necessary, to <decompose a system into as many concerns as necessary <combine them as required <ideally, to do this decomposition after the system has been developed. <This will: <reduce software complexity and improve comprehensibility. <promote traceability within and across artifacts <limit the impact of change, <facilitating evolution and non-invasive adaptation and customization. <facilitate reuse. <simplify component integration. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden IBM‘s Hyperspaces and Hyper/J <IBM uses the notion of hyperspaces for MDSOC. <The research tool they use is Hyper/J. <Hyper/J provides a powerful composition capability, to combine separated concerns selectively into an integrated program <Hyper/J can be used at any stage of the software lifecycle: Design, Implementation, Integration, Evolution, Reengineering <It uses standard Java and uses bytecode rewriting Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J Example: Simple Expression Editor <Tool to edit expressions of the form a = b + c * x <It contains a set of tools that share a common representation of expressions, the AST. <The set of tools should include the following: <Evaluation tool: Determines the result <Display tool: Depicts an expression program <Check tool: Checks an expression program for syntactic and semantic correctness. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J Example: Simple Expression Editor < Tools are implemented as operations on the AST classes. < The following concerns can be identified: <Classes/Objects <Features Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden SEE: Manual Solution: Visitor Pattern <Implementing visitor requires <design decision before implementation <specific design and programming model Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Exercise 11: Features and Visitor Implement the different features „operating“ on the AST using the visitor pattern. Discuss advantages and especially the drawbacks of this solution. Assuming, Hyper/J solves these problems – what features would you like Hyper/J to have? Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J Example: Additional Requirements <It should be possible to have versions of the SEE that include subsets of the tools and capabilities. <It should be possible to impose, optionally, checks for conformance to one or more programming styles. <It should be possible to log, selectively, the execution of the SEE. <Results in more concerns: <configurations <logging: Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J: Features to solve the problems <Multiple, arbitrary dimensions of concern. <Separation along these dimensions simultaneously. No dominant dimension! <The ability to handle new concerns, and new dimensions of concern, dynamically a posteriori. <Overlapping and interacting concerns; usually they are not orthogonal Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J: Concepts <A hyperspace is the problem space to be separated into concerns. <Each dimension in that space is a concern. <A unit is a program artifact, in Hyper/J only Java: <packages, interfaces, classes and members. <A concern mapping associates units (classes, interfaces, etc. ) with a dimension and a concern. artifact: dimension. concern <A hyperslice is set of concerns <that is declaratively complete. <I. e. it must declare everything to which they refer, it need not implement it! <This requirement reduces coupling. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J: Declarative completeness example <A hyperslice contains unit Plus. display(), which uses Plus. get. Operand() defined in Kernel hyperslice <To make the slice declaratively complete (i. e. compilable), it must supply its own version of Plus. get. Operand(), however, it need not implement it (abstract declaration). <Plus. display() then refers to this declaration <Later on, the local declaration is mapped to a suitable implementation in another hyperslice. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J: Concepts <A hypermodule is a <set of hyperslices being integrated <and a set of integration relationships, which specify how the hyperslices relate to one another. <Hyper/J provides a compositor tool to specify concerns, hyperslices, hypermodules, etc. and to compose them. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J: Example continued <The Java classes are implemented as usual (see class diagram) <We now want to factor out the Feature dimension and its concerns. <First, we create a hyperspace specification file that specifies the complete space: hyperspace Demo. Hyperspace composable class demo. Object. Dimension. *; Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J: Example continued <Then, we have to define the concerns mapping. Here, operations are mapped to concerns. package demo. Object. Dimension operation check operation display operation eval operation check_process operation display_process operation eval_process operation process Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG : Feature. Kernel : Feature. Check : Feature. Display : Feature. Eval : Feature. None
Moderne Softwareentwicklungsmethoden Hyper/J: Example continued <As a last step, we define the hypermodule specification file, which defines how the dimensions and concerns can be composed. hypermodule Demo. SEE hyperslices: Feature. Kernel, Feature. Check, Feature. Display; Relationships: merge. By. Name; equate operation Feature. Kernel. process, Feature. Check. check_process, Feature. Display. display_process; end hypermodule; Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J: Example continued <We then have to run the compositor tool: java com. ibm. hyperj -hyperspace %HYPERJ_DIR%/demo/Object. Dimension. hs -concerns %HYPERJ_DIR%/demo/Object. Dimension/concerns. cm -hypermodules %HYPERJ_DIR%/demo/Check. Display. hm -verbose <And then, we can run the application. Simple, isn‘t it? <By changing the hypermodule definition file, we can easily change the included concerns. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J: Example, adding a new Feature <We want to add the Style. Checking Feature, after the system is finished! <New package: demo. Style. Checker <Add this to the hyperspace configuration file: hyperspace Demo. Hyperspace composable class demo. Object. Dimension. *; composable class demo. Style. Checker. *; <. . . and the concern mapping: package demo. Style. Checker : Feature. Style. Checker Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Hyper/J: Example continued <The hypermodule configuration file: hypermodule Demo. SEE hyperslices: Feature. Kernel, Feature. Check, Feature. Display, Feature. Style. Checker; relationships: merge. By. Name; equate operation Feature. Kernel. process, Feature. Check. check_process, Feature. Display. display_process; set summary function for action Demo. SEE. Binary. Operator. check to action Demo. SEE. Expression. summarize. Check; end hypermodule; Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Exercise 12: Hyper/J The source on the previous page contains the set summary function specification. What do you think is it good for? Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
? Moderne Softwareentwicklungsmethoden MDOSC: Can it be used today? <Again, the concept is simple and can be used today. <Hyper/J as an implementation has been around for a while and is quite stable. <However, I would not recommend using it in industry projects, because it is not an established tool and approach. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Intentional Programming Background Basic Concepts IP System Architecture Active Source Stunning Features Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden IP Background <Intentional Programming (IP) has been a research project by Microsoft, lead by Charles Simonyi. <It has since been transferred to the Visual Tools development division. <As a consequence, it is very hard to obtain substantial information on the project. The best description I found is in Eisenecker and Czarnecki‘s book. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden IP Basics <IP is an extendible (meta)programming environment. <The environment and the language can be extended to contain (domain-specific) higher-level abstractions. <Extension libraries are used to supply the exetensions. <It allows extensions to the <Language <Compiler <Debugger <Editor <Version control Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden IP System itself <The IP system supports the extensibility by providing <a code transformation framework <compilation support protocols <debugging facilities that also allow the debugging of metacode <and standard APIs for accessing the various parts of the system. <Developers of extension libraries can make use of other extension libaries. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden IP System Architectural Overview <Important components <Editor & Browser <Reduction Engine <Debugger <VCS <Import Parsers <Reduction engine <±Compiler <No parser! <Creates R-Code <Reduction is applied repeatedly <Backend and Linker creates machine code Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden IP System Architectural Overview int x; x = 1; while ( x < 5 ) ++x; TEST: if ( x < 5 ) { ++x; goto TEST; } <Reduction engine 0 FAB 12 CF <±Compiler AFCD <No parser! DF 12 <Creates R-Code <Reduction is applied repeatedly <Backend and Linkter creates machine code Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden IP Core: Active Source <Source is not represented as ASCII text, instead it is Active Source: <Source elements are graph-structure, a kind of enhanced AST <Each element has a reference to its declaration, which can be in an extension libary. <methods operate on this tree, i. e. programming time behaviour can be specified Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Active Source Example int x; x = 1; while ( x < 5 ) ++x; Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Active Source at Programming-Time <The declarations of elements in an active source tree can point to definitions inside libraries. <These „types“ can contain operations to <render <type-in <reduce <debug <refactor <They are called by the framework at appropriate times. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden AST methods example: Type-In <The following shows support for typing in a simple expression: Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden More advanced support for type-in <The following shows support for handling matrices. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden More advanced support for type-in (II) <The following shows support for handling general mathematical formulas. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden More advanced support for type-in (III) <. . . electrical circuits Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden More advanced support for type-in (IV) <. . . or just some help in typing in normal code Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden More advanced support for type-in (V) <. . . or chinese Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
? Moderne Softwareentwicklungsmethoden IP: Can it be used today? <Yes, probably, but only by Microsoft <Parts have probably gone into. NET Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Thanks. . . <to the aspectj team for letting me use some material from their tutorial <Ulrich Eisenecker and Krzysztof Czarnecki for the permission to use some code examples and illustrations from their book „Generative Programming“ <The Hyper/J team their material for allowing me to use some of <Krzysztof Czarnecki for reviewing the slides and giving useful feedback <Andreas Bohn for scanning illustrations. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Resources <You will find information on many of the topics in this tutorial in the book Generative Programming by Ulrich Eisenecker and Krzysztof Czarnecki, Addison Wesley, 2000 <Information on generative programming on the web can be found at www. generative-programming. org and various conference workshop pages. <Information on aspect orientation can be found at aosd. net and www. aspectj. org. The former of the two contains a really good link collection. Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden Resources (II) <Information about Multi-Dimensional Separation of Concerns can be found at www. research. ibm. com/hyperspace/MDSOC. htm <Information on Intentional Programming is not available on the web anymore. Read E&C‘s book. <In general, all of these topics are still (at least partly) subject to ongoing research – chances are that you will find information at conferences and associated workshops. Examples: OOPSLA, ECOOP, OT, . . . Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG
Moderne Softwareentwicklungsmethoden The end. <Questions? <Criticism? <Opinions? build software like they build cars! Moderne Softwareentwicklungsmethoden copyright © 2001, MATHEMA AG






































































































































