Generative software product line development using variability-aware design patterns

https://doi.org/10.1016/j.cl.2016.08.006Get rights and content

Highlights

  • Use of design patterns in Software Product Lines to realize different features.

  • Variability-aware design patterns Observer, Strategy, Template Method and Composite.

  • Technology neutral specification and validity checks using role modeling.

  • Generative model-based implementation for Java, C++ and UML class diagrams.

  • Support for variability with Antenna, preprocessor, FOP, DeltaJ, DeltaEcore.

Abstract

Software Product Lines (SPLs) are an approach to reuse in-the-large that models a set of closely related software systems in terms of commonalities and variabilities. Design patterns are best practices for addressing recurring design problems in object-oriented source code. In the practice of implementing SPL, instances of certain design patterns are employed to handle variability, which makes these “variability-aware design patterns” a best practice for SPL design. However, currently there is no dedicated method for proactively developing SPLs using design patterns suitable for realizing variable functionality. In this paper, we present a method to perform generative SPL development with design patterns. We use role models to capture design patterns and their relation to a variability model. We further allow mapping of individual design pattern roles to (parts of) implementation elements to be generated (e.g., classes, methods) and check the conformance of the realization with the specification of the pattern. We provide definitions for the variability-aware versions of the design patterns Observer, Strategy, Template Method and Composite. Furthermore, we support generation of realizations in Java, C++ and UML class diagrams utilizing annotative, compositional and transformational variability realization mechanisms. Hence, we support proactive development of SPLs using design patterns to apply best practices for the realization of variability. We realize our concepts within the Eclipse IDE and demonstrate them within a case study.

Introduction

Design patterns are templates for standard solutions to recurring design problems, predominantly in object-oriented languages [1], e.g., Java, C++ or UML class diagrams (see Section 2.2). Software Product Lines (SPLs) are an approach to reuse in-the-large where a family of closely related software systems is represented in terms of commonalities and variabilities—often referred to as features (see Section 2.1). SPLs utilize, among others, object-oriented programming and modeling languages to realize features.

In our previous work [2], [3], we analyzed multiple SPLs for their use of design patterns. We found that instances of the design patterns Observer [1], Strategy [1], Template Method [1] and Composite [1] are used to explicitly realize variability. Furthermore, we determined that there also are common practices with regard to how the different entities of a design pattern are distributed to individual features of a feature model in and SPL. As an example, Fig. 1 illustrates the Observer pattern, where an entity produces state changes (Observable/Subject) that are received by a loosely coupled interested entity (Observer/ConcreteObserver), e.g., to react to these state changes. Within the exemplary usage of Fig. 1 in an SPL context, the concrete entities of the pattern (i.e., ConcreteObserver, Subject) are realized by different features than the more general entities (i.e., Observer, Observable). The features of the figure are abstractions from a concrete SPL we inspected.

Furthermore, we have determined that the distribution of a design pattern׳s entities to features follows specific rules [4] (see Section 3) in order to realize functionality associated with particular features. With these findings, design patterns can be considered a best practice in SPL design so that it seems well-advised to explicitly employ them in developing SPLs. A design pattern is instantiated by implementing its entities in a particular language, e.g., Java or UML, even though the structure of the pattern does not have to be matched exactly to be valid (see Section 2.2). Furthermore, the instantiation of variability-aware design patterns needs to incorporate the distribution of the individual entities of the design pattern to different features. Performing this procedure manually is both tedious and error-prone as the specification of the design pattern may inadvertently be violated by improper implementation.

To aid the process of applying variability-aware design patterns to SPLs as best practices for design, we present a generative method that allows tailoring a pattern׳s realization to a particular SPL and that generates realization artifacts that instantiate the pattern with specified parameters.

We provide definitions for the variability-aware versions of the design patterns Observer, Strategy, Template Method and Composite. Furthermore, we support generation of realizations in Java, C++ and UML class diagrams utilizing annotative, compositional and transformational variability realization mechanism (see Section 2.1).

The rest of this paper is structured as follows: Section 2 provides foundations of SPLs, design patterns and role modeling. Section 3 elaborates on how to specify variability-aware design patterns as reusable catalog entries and provides catalog pages for the variability-aware versions of the design patterns Observer, Strategy, Template Method and Composite. Section 4 introduces our method of applying variability-aware design patterns to SPLs by generating required realization artifacts that contain appropriate variability information. Section 5 elaborates on the model-based implementation of our method. Section 6 discusses how our approach can be integrated in proactive, reactive and extractive SPL development processes. Section 7 demonstrates the feasibility of our method within a case study. Finally, Section 8 discusses related work before Section 9 closes with a conclusion and an outlook to future work.

The work in this paper is mainly based on our previous work published in [5]. We improve over this work in the following points: For one, we define the variability-aware version of the Composite pattern and incorporate it into our generation facilities. Moreover, we provide detailed descriptions for each of the presented variability-aware design patterns in the form of a full catalog page. Furthermore, we extended our code generation facilities to also generate C++ code with appropriate preprocessor directives as annotative variability realization mechanism as is used frequently in industrial practice [6]. Accordingly, we extended our case study to incorporate the application of the Composite pattern and the generation of C++ code. In addition, we supply information on how to ease the application process of design patterns (see Section 4.3). Finally, we provide a detailed discussion on how to integrate our generative approach into SPL development processes for proactive, reactive and extractive development [7] (see Section 6).

Section snippets

Foundations

The work presented in this paper generates artifacts of (SPLs) by applying design patterns specified using role modeling. The following sections briefly introduce each of these constituents.

Specification of design patterns

As part of our previous work on analyzing SPLs [2], [3], we established that design patterns were not only used within individual features but also across features to realize variability. For example, we found the Observer pattern decomposed over several features (see Fig. 1) where the loose coupling for information on state changes is used for communication over various features, e.g., with the general roles of the design pattern (Observer/Observable) implemented within one feature and the

Application of design patterns

With the uniform and semi-formal specification of variability-aware design patterns presented in Section 3, it is possible to provide support for applying patterns in order to generate parts of SPL׳s realization artifacts (e.g., source code, design models). In the SPL context, design patterns may be used to implement functionality that is distributed over various features, e.g., an algorithm where the principle structure is defined in a base feature but where the specific parts vary depending

Implementation

We implemented the method to generate variability-aware design pattern instantiations as presented in this paper within the Eclipse IDE. Throughout the implementation, we utilize the Ecore metamodeling notation from the EMF: We created a textual DSL using Xtext7 of the EMF to specify patterns with their respective details according to Section 3. Fig. 28 shows an example of the DSL used to specify the Observer pattern.

We added three further metamodels for DPRMs, FRMs

Integration into software product line development processes

In SPL engineering, three principal types of SPL development may be distinguished: proactive, reactive and extractive development [7]. In the following, we elaborate on each of these types of development and discuss the relevance of our approach for each one of them.

Case study

To demonstrate the feasibility of our method, we performed a case study utilizing the presented generation procedure: In our previous work [4], we analyzed 8 FOP-based SPLs, realized in Java, for the usage of variability-aware design patterns. We found multiple instances of design patterns that were distributed across various features. Within the case study of this paper, we use our generative method to re-create instantiations of the respective design patterns that are similar to the ones we

Related work

Design patterns as an abstract design concept have been introduced by Gamma et al. [1] and since then there has been exhaustive research on design patterns as well as regular additions of new patterns [39], [40], [41], [42], [43]. For example, Zimmer [39] investigated the relationships between the design patterns proposed by Gamma et al. [1]. Gamma [40] and Bäumer et al. [43], proposed new design patterns solving more complex challenges in object-oriented design. Beck et al. [42] described the

Conclusion

In this paper, we presented a method to specify and apply variability-aware design patterns as best practices for SPL design within a generative procedure to create suitable implementations of a pattern. We specified variability-aware patterns with their respective data (name, intent, etc.) as well as role models for the design pattern (DPRM) as well as constraints on its variable nature within SPL (FRM). Using this schema, we provided catalog entries for the variability-aware versions of the

Acknowledgments

This work was partially supported by the DFG (German Research Foundation) under grant SCHA1635/2-2 and by the European Commission within the project HyVar (grant agreement H2020-644298).

References (57)

  • E. Gamma et al.

    Design patterns: elements of reusable object-oriented software

    (1994)
  • Schuster S, Schulze S, Schaefer I. Structural feature interaction patterns: case studies and guidelines. In:...
  • Schuster S, Schulze S. Object-oriented design in feature-oriented programming. In: Proceedings of the 4th international...
  • Schuster S. Pattern-based software product line design using role modeling [Diploma thesis]. Technische Universität...
  • Seidl C, Schuster S, Schaefer I. Generative software product line development using variability-aware design patterns....
  • Couto M, Valente M, Figueiredo E. Extracting software product lines: a case study using conditional compilation. In:...
  • Krueger C. Variation management for software production lines. Software product lines. Springer; 2002. p....
  • Kang K, Cohen S, Hess J, Novak W, Peterson A. Feature-oriented domain analysis (FODA) feasibility study. Technical...
  • K. Czarnecki et al.

    Formalizing cardinality-based feature models and their specialization

    Softw Process: Improve Pract

    (2005)
  • Kästner C, Apel S, Kuhlemann M. Granularity in software product lines. In: Proceedings of the 30th international...
  • I. Schaefer et al.

    Software diversitystate of the art and perspectives

    Int J Softw Tools Technol Transf

    (2012)
  • Batory D. Feature-oriented programming and the AHEAD tool suite. In: Proceedings of the 26th international conference...
  • Schaefer I, Bettini L, Bono V, Damiani F, Tanzarella N. Delta-oriented programming of software product lines. Software...
  • Clarke D, Helvensteijn M, Schaefer I. Abstract delta modeling. In: Proceedings of the ninth international conference on...
  • Riehle D. Describing and composing patterns using role diagrams. In: White object-oriented nights: proceedings of the...
  • Reenskaug T, Wold P, Lehne OA. Working with objects. The Oram software engineering method, Manning, Greenwich,...
  • Riehle D, Gross T. Role model based framework design and integration. In: Proceedings of the 13th ACM SIGPLAN...
  • Y. Smaragdakis et al.

    Mixin layersan object-oriented implementation technique for refinements and collaboration-based designs

    ACM Trans Softw Eng Methodol

    (2002)
  • Kästner C, Apel S, ur Rahman SS, Rosenmüller M, Batory D, Saake G. On the impact of the optional feature problem:...
  • E. Tsang

    Foundations of constraint satisfaction

    (1995)
  • Benavides D, Segura S, Trinidad P, Ruiz-Cortés A. Using Java CSP solvers in the automated analyses of feature models....
  • Benavides D, Trinidad P, Ruiz-Cortés A. Automated reasoning on feature models. In: Pastor, C, Falc ao e Cunha J.a.,...
  • Batory D. Feature models, grammars, and propositional formulas, software product...
  • Bracha G, Cook W. Mixin-based inheritance. In: Proceedings of the European conference on object-oriented programming on...
  • Duggan D, Sourelis C. Mixin modules. In: Proceedings of the first acm sigplan international conference on functional...
  • Bouassida N, Kouas A, Ben-Abdallah H. A design pattern recommendation approach. In: IEEE second international...
  • Palma F, Farzin H, Guéhéneuc Y-G, Moha N. Recommendation system for design patterns in software development: an DPR...
  • Kung DC, Bhambhani H, Shah R, Pancholi G. An expert system for suggesting design patterns—a methodology and a...
  • Cited by (8)

    • Features, Believe It or Not!: A Design Pattern for First-Class Citizen Features on Stock JVM

      2022, 26th ACM International Systems and Software Product Line Conference, SPLC 2022 - Proceedings
    • An Extensible Compiler for Implementing Software Design Patterns as Concise Language Constructs

      2021, International Journal of Software Engineering and Knowledge Engineering
    View all citing articles on Scopus
    View full text