moderne softwareentwicklungsmethoden copyright © 2001, mathema ag moderne...

Click here to load reader

Post on 26-Mar-2015

226 views

Category:

Documents

4 download

Embed Size (px)

TRANSCRIPT

  • Slide 1

Moderne Softwareentwicklungsmethoden copyright 2001, MATHEMA AG Moderne Softwareentwicklungsmethoden Workshop: Moderne Softwareentwicklungs- Methoden Teil 1: AOP, MDSOC, GP, IP Teil 2: eXtreme Programming Markus Vlter [email protected] Michael Wiedeking [email protected] Slide 2 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 AspectJ Sally Jenerator and AOP Slide 3 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 Slide 4 Moderne Softwareentwicklungsmethoden copyright 2001, MATHEMA AG Moderne Softwareentwicklungsmethoden The big picture Product Line Engineering Variability Analysis How AOP, GP, IP and MDSOC can help Slide 5 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 (QoS) 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 Slide 6 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 (QoS) requirements, potential for future growth 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 Software Family as defined by Parnas in 1976: We consider a set of programs to constitute a family whenever it is worthwhile to study programs from the set by first studying the common properties of the set and then determining the special properties of the individual family members. Slide 7 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 Slide 8 Moderne Softwareentwicklungsmethoden copyright 2001, MATHEMA AG Moderne Softwareentwicklungsmethoden Product Line Engineering: Process AOP, IP, GP & MDSOC are located here. But first... Slide 9 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 Slide 10 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. Slide 11 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 Slide 12 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 A320 Slide 13 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 Slide 14 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) Slide 15 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 Slide 16 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 Slide 17 Moderne Softwareentwicklungsmethoden copyright 2001, MATHEMA AG Moderne Softwareentwicklungsmethoden Binding Times and consequences (at runtime) Slide 18 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 Slide 19 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. Slide 20 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. Slide 21 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 Slide 22 Moderne Softwareentwicklungsmethoden copyright 2001, MATHEMA AG Moderne Softwareentwicklungsmethoden Multi-Dimensional Variability What, if an certain feature cannot be decomposed along this same dimension? Slide 23 Moderne Softwareentwicklungsmethoden copyright 2001, MATHEMA AG Moderne Softwareentwicklungsmethoden Multi-Dimensional Variability: Apache Example Logging Session Expiration Slide 24 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 Slide 25 Moderne Softwareentwicklungsmethoden copyright 2001, MATHEMA AG Moderne Softwareentwicklungsmethoden AOP generalized AOP uses one primary decomposition structure (classes) and several additional aspects that cross- cut 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. Slide 26 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 Slide 27 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. Slide 28 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,... Slide 29 Moderne Softwareentwicklungsmethoden copyright 2001, MATHEMA AG Moderne Softwareentwicklungsmethoden Relations among the mentioned techniques Slide 30 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 ? ? Slide 31 Moderne Softwareentwicklungsmethoden copyright 2001, MATHEMA AG Moderne Softwareentwicklungsmethoden Generative Programming Principles Compile-time Metaprogramming Jenerator Generative Programming for Java Other GP tools Slide 32 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 Slide 33 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 Slide 34 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 Slide 35 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) Slide 36 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 Slide 37 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 Slide 38 Moderne Softwareentwicklungsmethoden copyright 2001, MATHEMA AG Moderne Softwareentwicklungsmethoden GP Example: C++ Template Metaprogramming struct SimpleBoundsChecker; template class Vector { public: //... ElementType& at(const int& i) { BoundsChecker::checkBounds(i,length); //... } //... }; struct OutOfBounds {}; struct SimpleBoundsChecker { static void checkBounds(const int& i,const int& length) { if(i =length) throw OutOfBounds(); } }; struct EmptyBoundsChecker { static void checkBounds(const int& i,const int& length) { } }; //... int main() { Vector v1; //v1 uses SimpleBoundsChecker Vector v2; //v2 uses EmptyBoundsChecker return 0; } Slide 39 Moderne Softwareentwicklungsmethoden copyright 2001, MATHEMA AG Moderne Softwareentwicklungsmethoden GP Example: C++ Template Metaprogramming struct SimpleBoundsChecker; template class Vector { public: //... ElementType& at(const int& i) { BoundsChecker::checkBounds(i,length); //... } //... }; struct OutOfBounds {}; struct SimpleBoundsChecker { static void checkBounds(const int& i,const int& length) { if(i =length) throw OutOfBounds(); } }; struct EmptyBoundsChecker { static void checkBounds(const int& i,const int& length) { } }; //... int main() { Vector v1; //v1 uses SimpleBoundsChecker Vector v2; //v2 uses EmptyBoundsChecker return 0; } combines the classes at compile time Creates only those versions that are really used Inlining is used to improve runtime performance (or reduce code size) Calls to empty operations are eliminated Slide 40 ::RET) = " 4), short, int>::RET) ::RET i; //the type of i is int! }"> 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 using namespace std; template struct IF { typedef Then RET; }; //specialization for condition==false template struct IF { typedef Else RET; }; void main() { cout 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 using namespace std; #include "../meta/meta.h" using namespace meta; struct Stop { enum { RET = 1 }; }; template struct Factorial { typedef IF >::RET PreviousFactorial; enum { RET = (n==0) ? PreviousFactorial::RET : PreviousFactorial::RET * n }; }; void main() { cout ::RET > 1); //initialize with smallest struct NilCase {}; template struct CASE { enum { tag = tag_ }; typedef Type_ Type; typedef Next_ Next; }; // test struct A {static void exec(){ cout