Reuse Strategies: Implementing Product-Line Features with Component Reuse

Archived publication by Dr. Martin L. Griss (1999)

Reuse Strategies

Implementing Product-Line Features

with Component Reuse

(OBM13: Draft 1.5, 5/21/99;6/7/99;6/16/99;6/20/99;7/5/99)

Martin L. Griss, Laboratory Scientist, (griss@hpl.hp.com)

Software Technology Laboratory

Hewlett-Packard Laboratories

(Submitted to Component Strategies, July 1999.)

Product lines offer substantial opportunities for reuse

Today, it is increasingly important to manage related products as members of a product line. Systematic component reuse can play a significant role in reducing costs, decreasing schedule and ensuring commonalty of features across the product-line. Business managers can make strategic investments in creating and evolving components that benefit the whole product-line, not just a single product. Studies of successful programs show that most often, successful reuse is associated with a product line. Common components are reused multiple times, and defect repairs and enhancements to one product can be rapidly propagated to other members of the product line.

A product line is a set of products that share a common set of requirements, but also exhibit significant variability in requirements. This commonality and variability can be exploited by treating the set of products as a family [Parnas 1971, 1978].

A feature is a product characteristic that users and customers view as important in describing and distinguishing members of the product-line. A feature can be a specific requirement, a selection amongst optional or alternative requirements, or related to certain product aspects, such as functionality, usability, and performance, or implementation aspects, such as size, execution platform or compatibility with certain standards. Members of a product line might all exist at one time, or be related to the evolution of the product line.

For example, each different member of a word processing product line might optionally provide an outline mode, spell-checking, grammar correction, or diagrams, may run in Windows or Unix, be large or small, support a small number of files or large number files, etc. Some word processors might have a minimal spell checker, while others could have a large spell checker integrated with a grammar corrector.

A product line can be built around the set of reusable components. The approach is based on analyzing the products to determine common and variable features, and then developing a product structure and implementation strategy that expresses this commonality in terms of a set of reusable components.

Each component will capture some of the set of features, or allow features to be built up by combining components. For example, each word processor in the product-line above might share a common editing component, and optionally one or more components for spell-checking, diagramming, etc. These components may be combined to produce a variety of similar word processors, only some of which would be viable products. Often, these components are used directly without change; in other cases the components are adapted in someway to account for differences in the products that are not expressible by just selecting alternative components; and in yet other cases, the components are substantially modified before inclusion into the product. Thus, some components would be used as is, some would-be parameterized and others would come in sets of plug compatible alternatives with different characteristics to satisfy the features.

Domain analysis helps find features

Techniques called domain analysis or domain engineering [Arango 1994;Kang 1990, 1998; Griss 1998] are used to systematically extract features from existing or planned members of a product-line. Features trees are used to relate features to each other in various ways, showing sub-features, alternative features, optional features, dependent features or conflicting features. These methods (e.g. FODA, FeatureRSEB, FAST, FORM) are used to cluster sets of features to shape the design of a set of components that cover the product line.

Once designed, each component is assigned to a component development team which develops and maintains it. Products are assigned to feature teams who select a set of features that define the products, and then select and adapt the appropriate components to cover the features and produce the desired product.

This is a good plan, and works extremely well when the set of features decomposes nicely into a set of almost independent, fixed components, where very few features span multiple components. For example, products dominated by mathematical and statistical components.

Tracing features to components gets complex

Things are not always this simple.

Things get a little more complex when components have compile time or run time parameters that essentially generate a customized component. Here one has to keep track of which parameter settings relate to which version.

Things get much more complicated when the code that implements a particular features or closely related features needs to be spread across multiple products, classes or modules and is intertwined or tangled with code implementing other (groups of) features. Here maintenance and evolution becomes very complicated, since the change in a particular feature may require changes all over the place.

The problem is that individual features do not typically trace directly to an individual component or cluster of components -- this means as a product is defined by selecting a group of features, a carefully coordinated and complicated mixture of parts of different components are involved. This is typically referred to as the requirements traceability or the feature-interaction problem.

How should we address this problem? The conventional approach is to build fairly complex maps (essentially hyper-webs) from features to products, and manage the evolution of the features by managing the evolution of the components. In the past, this has been done manually, but more recently powerful requirements tracing and management tools have made this somewhat easier.

Even with tools, what makes this complex is that when one feature changes, code in many modules will have to change; to find and change this code requires the code corresponding to this feature to be disentangled from the code for other features. A real pile of spaghetti! (hence my Italian connections -J )

One observation is that typically individual features (or small sets of related features) change more or less independently from other features, and thus a group of code changes can be related to threads drawn from a few related features. This is the same observation that suggest that use-case driven development is so powerful; it is complete usecases that change or are selected almost independent.

Untangling the feature web

There are three different approaches that can be used to approach this problem. Typically, some combination of these is used in practice. Each approach has benefits and drawbacks.

  1. Traceability - using hyperweb-like tools to help find and manage threads corresponding to one feature (e.g., program slicing, browsers, code coloring. See for example the DOORS or Calibre RM requirements management tools, also xxx…). In some cases, the threads from requirements through features to design and code are maintained as the software is built; in others, the threads are discovered using maintenance and analysis tools. This is often hard to do, and leads to a complex set of multiple versions of multiple components. When a feature is changed, lots of code in many components is touched, and so many components have to be retested and revalidated after a change.
  2. Architecture - use tools and techniques (patterns, styles, software bus, middleware) and a good decomposition into separate pieces that are more orthogonal, localizing changes. This often leads to a better structure and a more maintainable, flexible system. However, discovering and maintaining a good design, requires a lot of skill (and some luck) in choosing a decomposition that anticipates changes. Different decompositions are more or less robust against different classes of change.
  3. Composition or "weaving" of program fragments - the feature decomposition is used directly to produce pieces of software ("aspects") that are assembled in some manual or mechanical way into complete components or products. Up to now, a systematic approach to this has been lacking, and mixture of manual techniques, with macros or compile time switches has been used to do this in a somewhat clumsy way.

Feature-driven, aspect-based product line engineering.

A systematic approach is emerging. Over the last several years, a number of techniques have been developed to make the "composition and weaving" approach to feature-driven design and development of software practical. The idea is to directly implement some feature (sometimes called aspect when referring to solution or design features) as a fragment of code, and then use some mechanism or tool to combine these fragments (sometimes called facets) together into complete modules.

The key idea is to identify a useful class of program fragments that can be mechanically combined using some formal tool, and associating these fragments with a of the software.

The idea is not to directly manage the resulting components, but to directly manage only the aspects and their related facets, and to dynamically generate a version of the component as needed.

There are several techniques, mechanisms and tools that can be used. These differ primarily in the granularity and language level of fragments and the legal ways in which they can be combined. For example, does code get woven at the procedure level, at the method level or within individual statements. Can the approach be seen as a just a disciplined way of using a standard language feature (such as templates or inheritance) or is a new tool added that effectively changes the language (such as a preprocessor or macro).

Some of these include:

  • Macros - typically look like procedure calls, but in fact create inline code, overcoming a concern about performance with breaking a systems into many small procedures. Some macros can generate alternative pieces of code using conditional expansion, and testing compile time parameters.
  • OO inheritance and frameworks- subclasses define new methods that "override" the definition of some default methods. By using multiple-inheritance of "mixin" classes, the subclasses are essentially a method level combination of methods (as class fragments) drawn from several different sources. The subclasses and mixins, can be thought of as the component fragments being combined into complete components or complete applications.
  • C++ templates - the body of a method, or of several methods, is created by composing fragments. This was raised to a high-art form in the C++ Standard Template Library (STL), in which a class was constructed from a composition of an Algorithm, a Container, an Element, and several Adapter aspects.[Musser1996].
  • Frame-based generators - Paul Bassett [Bassett 1997] shows how a simple frame-based "generator" (he calls it an "assembler") composes code fragments from several frames. Each frame deals with one or more aspects of the system being generated.
  • System generators - Batory's GenVoca and P++ [Batory 1992, 1996]- a specialized preprocessor assembles systems from specifications of components, and composition as layers. These techniques have been applied to customizable databases, compilers, data structure libraries and other domains.
  • Aspect-oriented programming - Kiczales and colleagues have defined and developed tools (such as AspectJ) use identified places in source code (such as Java) at which to insert or modify code fragments; thus weaving occurs at the statement level, modifying and extending a relatively complete program.
  • Subject-oriented programming (and design) - Osher, Harrison and colleagues [Harrison 93; Tarr 1999; Walker 1999] represents each concern or feature as a separate aspect, implemented or design as a separate facet, and then independently selected, customized and finally combined together to produce the complete program.

These code fragments are sometimes called facets or are referred to by their corresponding aspects, subjects or concerns expressing the features, depending on the granularity and how they will be woven together. As experience with C++ templates has grown, it has been shown that some of the weaving thought to need a system generator or special aspect-oriented generator, could in fact be accomplished by clever decomposition into template elements, using a combination of C++ templates and inheritance called a "mixin layer". For example, the C++ STL template library, work by VanHilst and Notkin [VanHilst 1996 using templates to implement role mixins, and later work by Smaragdakis and Batory[ Smaragdakis 1998] showing how P++ and Genvoca style composition [Batory 1992] can use a more powerful C++ template-based mixin layer idiom, and so avoid the need for a special generator (though more disciplined use seems needed)..

Feature engineering drives aspect engineering.

Thus the systematic approach becomes quite simple in concept:

  1. Use a feature-driven analysis and design method, such as FeaturRSEB to develop a feature model and high-level design with explicit variability and traceability. The feature diagram is developed in parallel with other diagrams as an index and structure for the product line family usecases, and class models. Features are traced to variability in the models. [Griss98]. The design and implementation models will show explicit patterns of variability
  2. Select one or more aspect oriented implementation techniques, depending on the granularity of the variable design and implementation features, and the patterns of their combination.
  3. Express the aspects using the chosen mechanism
  4. Design complete applications by selecting and composing features, which then select and compose aspects, weaving the resulting code out of corresponding fragments.

Obviously, this simple prescription is not a complete method, but does suggests that product line architects and component and framework designers should now become aware of feature and aspect engineering, and begin to use these ideas to structure their models and designs. Then they can structure the implementation, using OO inheritance and templates in a disciplined way, or perhaps use one of the generators, to explicitly manage and compose aspects traceable from features into members of the product family.

References

[Arango 1994] G Arango, Domain Analysis Methods, in W. Schäfer et al., Software Reusability, Ellis Horwood, Hemel Hempstead, UK, 1994.

[Basset 1996] PG Bassett Framing Reuse: Lessons from the Real World, Prentice Hall 1996.

[Batory 1992] D Batory and S O'Malley. The design and implementation of heirarchical software systems with reusable components. ACM Transactions on Software Engineering and Methodology, 1(4):355-398, October 1992.

[Batory 1996] D Batory, "Subjectivity and GenVoca Generators,", Proc. ICSR 96, Orlando, FLA, IEEE,April 1996, pp.166-175.

[Buschman 1996] F Buschmann et. al. Pattern-Oriented Software Architecture - A System of Patterns. John Wiley & sons, 1996.

[Gamma 1994] E Gamma, R Helm, R. Johnson and J. Vlissides, Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley, 1994.

[Garlan 1996] D. Garlan and M. Shaw, Software Architecture, Perspectives on an Emerging Discipline, Prentice-Hall, 1996.

[Griss 1998] M. Griss, J. Favaro and M. D'allesandro, "Integrating Feature Modeling with the RSEB," Proceedings of ICSR98, Victoria, BC, IEEE, June 1998, pp. 36-45.

[Harrison 1993] W Harrison and H Ossher, "Subject-oriented Programming (a critiques of pure objects)," Proc. OOPSLA 93Washington, DC, Sep 1993, 411-428, ACM.

[Jacobson 1997] I. Jacobson, M. Griss, and P. Jonsson, Software reuse: Architecture, Process and Organization for Business Success, Addison-Wesley-Longman, 1997.

[Kang 1990] KC Kang et al, Feature-Oriented Domain Analysis Feasibility Study, SEI Technical Report CMU/SEI-90-TR-21, November 1990 (See more recent paper, ICSE CBSE workshop?).

[Kang 1998] KC Kang et al, FORM: A feature-oriented reuse method with domain-specific architectures," Annals of Software Engineering, V5, pp 143-168, 1998.

[Kang 1999] KC Kang, Issues in Component-Based Software Engineering, ICSE CBSE workshop position paper,IEEE, Los Angeles, May 1999.

[Kicazales 1997] G. Kicazales, J Lamping, et al, "Aspect Oriented Programming," , Proc. ECOOP 199, Springer-Verlag, June 1997, 220-242..

[Musser 1996] D Musser and A Saini, STL Tutorial and Reference Guide, Addison-Wesley, 1996.

[Parnas 1971]. D Parnas, "Program families

[Parnas 1972]. DL Parnas, "On the criteria to be used in decomposing systems into modules," CACM, 15(12):1053-1058, Dec 1972.

[Parnas 1979]. DL Parnas, "Designing Software for Ease of Extension and Contraction,", IEEE Transactions on Software Engineering, v 5, #6, pp 310-320, Mar 1979

[Smaragdakis 1998] Y Smaragdakis and D Batory, "Implementing Reusable Object-Oriented Components," Proc. of ICSR 98, Victoria, BC, June 1998, pp36-45.

[Smaragdakis 1998a] Y Smaragdakis and D Batory, "Implementing Layered Designs with Mixin Layers," Proc. of ECOOP98, 1998.

[Smaragdakis 1999] Y Smaragdakis, "Reusable Object-Oriented Components," Proc. Of WISR 9, Austin, Tx, Jan 7-9, 1999,

[Tarr 1999] P Tarr, H Ossher, W Harrison and SM Sutton, Jr., "N degrees of Separation: Multi-dimensional separation of concerns," Proc. ICSE 99, IEEE, Las Angeles, May 1999, 107-119.

[VanHilst 1996] M. Van Hilst and D. Notkin, "Using C++ Templates to Implement Role-Based Designs," JSSST Symposium on Object technologies for Advanced Software, Springer-Verlag, 1996, 22-37

[VanHilst 1996a] M. Van Hilst and D. Notkin, "Using Role Components to Implement Collaboration-Based Designs," Proc. OOPSLA96, 1996, 359-369.

[VanHilst 1996b] M. Van Hilst and D. Notkin, "Decoupling Change From Design," ACM SIGSOFT, 1996.

[Walker 1999] RJ Walker, ELA Banniassad and GC Murphy, An Initial Assessment of Aspect Oriented Programming," Proc. ICSE 99, IEEE, Las Angeles, May 1999, 120-130.