Lecture Notes in Computer Science Commenced Publication in 1973 Founding and Former Series Editors: Gerhard Goos, Juris Hartmanis, and Jan van Leeuwen
Editorial Board David Hutchison Lancaster University, UK Takeo Kanade Carnegie Mellon University, Pittsburgh, PA, USA Josef Kittler University of Surrey, Guildford, UK Jon M. Kleinberg Cornell University, Ithaca, NY, USA Alfred Kobsa University of California, Irvine, CA, USA Friedemann Mattern ETH Zurich, Switzerland John C. Mitchell Stanford University, CA, USA Moni Naor Weizmann Institute of Science, Rehovot, Israel Oscar Nierstrasz University of Bern, Switzerland C. Pandu Rangan Indian Institute of Technology, Madras, India Bernhard Steffen University of Dortmund, Germany Madhu Sudan Microsoft Research, Cambridge, MA, USA Demetri Terzopoulos University of California, Los Angeles, CA, USA Doug Tygar University of California, Berkeley, CA, USA Gerhard Weikum Max-Planck Institute of Computer Science, Saarbruecken, Germany
5791
Stephen H. Edwards Gregory Kulczycki (Eds.)
Formal Foundations of Reuse and Domain Engineering 11th International Conference on Software Reuse, ICSR 2009 Falls Church, VA, USA, September 27-30, 2009 Proceedings
13
Volume Editors Stephen H. Edwards Department of Computer Science Virginia Tech Blacksburg, VA, USA E-mail:
[email protected] Gregory Kulczycki Department of Computer Science Virginia Tech, Northern Virginia Center Falls Church, VA, USA E-mail:
[email protected]
Library of Congress Control Number: 2009934448 CR Subject Classification (1998): D.2.13, D.2, D.3, D.1, D.3.3 LNCS Sublibrary: SL 2 – Programming and Software Engineering ISSN ISBN-10 ISBN-13
0302-9743 3-642-04210-4 Springer Berlin Heidelberg New York 978-3-642-04210-2 Springer Berlin Heidelberg New York
This work is subject to copyright. All rights are reserved, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, re-use of illustrations, recitation, broadcasting, reproduction on microfilms or in any other way, and storage in data banks. Duplication of this publication or parts thereof is permitted only under the provisions of the German Copyright Law of September 9, 1965, in its current version, and permission for use must always be obtained from Springer. Violations are liable to prosecution under the German Copyright Law. springer.com © Springer-Verlag Berlin Heidelberg 2009 Printed in Germany Typesetting: Camera-ready by author, data conversion by Scientific Publishing Services, Chennai, India Printed on acid-free paper SPIN: 12752911 06/3180 543210
Preface
ICSR is the premier international conference in the field of software reuse. The main goal of ICSR is to present the advances and improvements within the software reuse domain, as well as to promote interaction between researchers and practitioners. The 11th International Conference on Software Reuse (ICSR 2009) was held during September 27–30, 2009 in Falls Church, VA, USA. 2009 was the year that ICSR went back to its roots. The theme was “Formal Foundations of Reuse and Domain Engineering.” We explored the theory and formal foundations that underlie current reuse and domain engineering practice and looked at current advancements to get an idea of where the field of reuse was headed. Many of the papers in these proceedings directly reflect that theme. The following workshops were held in conjunction with ICSR 2009: – – – –
Second Workshop on Knowledge Reuse (KREUSE 2009) RESOLVE 2009: Software Verification – the Cornerstone of Reuse First International Workshop on Software Ecosystems International Workshop on Software Reuse and Safety (RESAFE 2009)
Aside from these workshops and the papers found here, the conference also included five tutorials, eight tool demos, and a doctoral symposium. Links to all of this information and more can be found at the ICSR 11 conference website at icsr11.isase.org. September 2009
Stephen Edwards Gregory Kulczycki
VI
Preface
Welcome Message from the General Chairs Welcome to ICSR11. This conference began as an International Workshop on Software Reuse in 1991, and became a full conference in 1994. ICSR is currently managed by the ISASE International Society for the Advancement of Software Education. The ISASE website—www.isase.us—contains information about past ICSR proceedings and is a good place to check for future ICSRs. September 2009
John Favaro Bill Frakes
Organization
General Chairs Program Chairs Demos Chair Tutorials Chair Workshops Chair Doctoral Symposium Chair Corporate Donations Chairs
John Favaro (INTECS, Italy) and Bill Frakes (Virginia Tech CS, USA) Stephen Edwards (Virginia Tech CS, USA) and Greg Kulczycki (Virginia Tech CS, USA) Cl´audia Werner (Federal University of Rio de Janeiro Brazil) Stan Jarzabek (National University of Singapore) Murali Sitaraman (Clemson University CS, USA) Jason Hallstrom (Clemson University CS, USA) Asia – Kyo Kang (Pohang University, Korea) South America – Cl´ audia Werner (Federal University of Rio de Janeiro, Brazil) Europe – Jaejoon Lee (University of Lancaster, UK) and Davide Falessi (University of Rome Tor Vergata, Italy) US – Okan Yilmaz (NeuStar Inc., USA)
Program Committee Colin Atkinson Don Batory Ted Biggerstaff Martin Blom Cornelia Boldyreff Steve Edwards Davide Falessi John Favaro Bill Frakes Jason Hallstrom Stan Jarzabek Kyo Kang Greg Kulczycki Jaejoon Lee Chuck Lillie Wayne Lim Juan Llorens Brian Malloy Hong Mei
University of Mannheim, Germany University of Texas Austin, USA Software Generators, USA Karlstad University, Sweden University of Lincoln, UK Virginia Tech, USA University of Rome Tor Vergata, Italy INTECS, Italy Virginia Tech, USA Clemson University, USA National University of Singapore, Singapore Pohang University, Korea Virginia Tech, USA University of Lancaster, UK ISASA, USA Infosys, USA University of Madrid Carlos III, Spain Clemson University, USA Peking University, China
VIII
Organization
Maurizio Morisio Dirk Muthig Jefferey Poulin Ruben Prieto-Diaz Michael (Eonsuk) Shin Alberto Sillitti Murali Sitaraman Bruce Weide Cl´audia Werner Okan Yilmaz
Politecnico di Torino, Italy Fraunhofer IESE, Germany Lockheed, USA University of Madrid Carlos III, Spain Texas Tech University, USA University of Bolzano, Italy Clemson University, USA Ohio State University, USA Federal University of Rio de Janeiro, Brazil NeuStar Inc., USA
Sponsoring Institutions Virginia Tech, Falls Church, VA, USA International Society for the Advancement of Software Education, USA National Science Foundation, USA Software Generators, USA Reuse Software Engineering, Brazil Pohang University of Science and Technology, Korea
Table of Contents
Component Reuse and Verification Consistency Checking for Component Reuse in Open Systems . . . . . . . . . Peter Henderson and Matthew J. Henderson
1
Generating Verified Java Components through RESOLVE . . . . . . . . . . . . . Hampton Smith, Heather Harton, David Frazier, Raghuveer Mohan, and Murali Sitaraman
11
Increasing Reuse in Component Models through Genericity . . . . . . . . . . . . Julien Bigot and Christian P´erez
21
Verifying Component-Based Software: Deep Mathematics or Simple Bookkeeping? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Jason Kirschenbaum, Bruce Adcock, Derek Bronish, Hampton Smith, Heather Harton, Murali Sitaraman, and Bruce W. Weide
31
Feature Modeling Extending FeatuRSEB with Concepts from Systems Engineering . . . . . . . John Favaro and Silvia Mazzini
41
Features Need Stories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Sidney C. Bailin
51
An Optimization Strategy to Feature Models’ Verification by Eliminating Verification-Irrelevant Features and Constraints . . . . . . . . . . . Hua Yan, Wei Zhang, Haiyan Zhao, and Hong Mei
65
Reusable Model-Based Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Erika Mir Olimpiew and Hassan Gomaa
76
Generators and Model-Driven Development A Case Study of Using Domain Engineering for the Conflation Algorithms Domain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Okan Yilmaz and William B. Frakes
86
Model Transformation Using Graph Transactions . . . . . . . . . . . . . . . . . . . . Leila Ribeiro, Luciana Foss, Bruno da Silva, and Daltro Nunes
95
Refactoring Feature Modules . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Martin Kuhlemann, Don Batory, and Sven Apel
106
X
Table of Contents
Variability in Automation System Models . . . . . . . . . . . . . . . . . . . . . . . . . . . Gerd Dauenhauer, Thomas Aschauer, and Wolfgang Pree
116
Industry Experience A Case Study of Variation Mechanism in an Industrial Product Line . . . Pengfei Ye, Xin Peng, Yinxing Xue, and Stan Jarzabek Experience Report on Using a Domain Model-Based Extractive Approach to Software Product Line Asset Development . . . . . . . . . . . . . . . Hyesun Lee, Hyunsik Choi, Kyo C. Kang, Dohyung Kim, and Zino Lee Reuse with Software Components - A Survey of Industrial State of Practice . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Rikard Land, Daniel Sundmark, Frank L¨ uders, Iva Krasteva, and Adnan Causevic
126
137
150
Product Lines Evaluating the Reusability of Product-Line Software Fault Tree Analysis Assets for a Safety-Critical System . . . . . . . . . . . . . . . . . . . . . . . . . Josh Dehlinger and Robyn R. Lutz
160
Feature-Driven and Incremental Variability Generalization in Software Product Line . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Liwei Shen, Xin Peng, and Wenyun Zhao
170
Identifying Issues and Concerns in Software Reuse in Software Product Lines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Meena Jha and Liam O’Brien
181
Reuse of Architectural Knowledge in SPL Development . . . . . . . . . . . . . . . Pedro O. Rossel, Daniel Perovich, and Mar´ıa Cecilia Bastarrica
191
Reuse and Patterns Introducing Motivations in Design Pattern Representation . . . . . . . . . . . . Luca Sabatucci, Massimo Cossentino, and Angelo Susi
201
The Managed Adapter Pattern: Facilitating Glue Code Generation for Component Reuse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Oliver Hummel and Colin Atkinson
211
Reusing Patterns through Design Refinement . . . . . . . . . . . . . . . . . . . . . . . . Jason O. Hallstrom and Neelam Soundarajan
225
Table of Contents
XI
Service-Oriented Environments Building Service-Oriented User Agents Using a Software Product Line Approach . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Ingrid Nunes, Carlos J.P. de Lucena, Donald Cowan, and Paulo Alencar
236
DAREonline: A Web-Based Domain Engineering Tool . . . . . . . . . . . . . . . . Raimundo F. Dos Santos and William B. Frakes
246
Extending a Software Component Repository to Provide Services . . . . . . Anderson Marinho, Leonardo Murta, and Cl´ audia Werner
258
A Negotiation Framework for Service-Oriented Product Line Development . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Jaejoon Lee, Gerald Kotonya, and Daniel Robinson
269
Ranking and Selecting Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Alberto Sillitti and Giancarlo Succi
278
A Reusable Model for Data-Centric Web Services . . . . . . . . . . . . . . . . . . . . Iman Saleh, Gregory Kulczycki, and M. Brian Blake
288
Author Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
299
Consistency Checking for Component Reuse in Open Systems Peter Henderson1 and Matthew J. Henderson2 1
Electronics and Computer Science, University of Southampton, Southampton, UK
[email protected] 2 Mathematics and Computer Science, Berea College, Berea, KY 40404, USA matthew
[email protected]
Abstract. Large scale Open Systems are built from reusable components in such a way that enhanced system functionality can be deployed, quickly and effectively, simply by plugging in a few new or revised components. At the architectural level, when new variations of a system are being planned by (re)configuring reusable components, the architecture description can itself become very large and complex. Consequently, the opportunities for inconsistency abound. This paper describes a method of architecture description that allows a significant amount of consistency checking to be done throughout the process of developing a system architecture description. An architectural design tool is described that supports consistency checking. This tool is designed to support component reuse, incremental development and collaborative working, essential for developing the architecture description of large systems.
1 Introduction Systems Architecture is that branch of Information System design that determines the overall structure and behaviour of a system to be built. Typically, an architecture is captured as an evolving set of diagrams and specifications, put together by a team of System Architects and iteratively refined over a period of consultation with the customers for the solution. The extent to which the architecture represents a buildable or procurable solution depends a great deal on the consistency and completeness of the architecture description and the extent to which it can be validated prior to commitment to procure. Validation of the architecture as early as possible in the process of development is important. This aspect of System Engineering is not well supported by tools. In this paper we advocate an approach to architecture description that lends itself to validation throughout architecture development. Open Systems have modular, or component-based, architectures based on a catalogue of reusable components with publicly maintained interfaces. Devising a new configuration involves selecting reusable components from the catalogue, devising new ones or variations of existing ones, and plugging them together according to the architecture description. Opportunities for inconsistent reuse of existing components are particular pitfalls which need to be avoided eventually, but which need, for pragmatic S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 1–10, 2009. c Springer-Verlag Berlin Heidelberg 2009
2
P. Henderson and M.J. Henderson
reasons, to be tolerated during design and development of a complex architecture description. The key idea is that the architects define a metamodel that enumerates the types of entities they are going to use in their description, along with the relationships between these entities. For example, as in this paper, they might choose to describe their architecture in terms of components and interfaces. As part of the metamodel, the architects will also specify constraints which a valid description must satisfy. Validation of the architecture description comprises checking the extent to which these constraints are satisfied. We have developed a tool, WAVE, to support this approach [1].
2 Background In Systems Engineering, in particular for software intensive systems, the design of a solution is normally developed around a system architecture.The description of this architecture is a shared model around which the architects work to understand the customer requirements and how these can be mapped on to programs and databases to realise a solution. The field of architecture description is now relatively mature [2,3,4,5,6,7,8]. Specific approaches to architecture description have, in many respects, found their way into standard representations such as UML [9] and SysML [10], so it is now quite common to find these notations in use in industrial projects. There are other approaches to architecture description [11,12,13,14,15,16,17,18,19,20,21,22] but these are generally ideas that are readily adopted as specialisations of the standard notations. Indeed, the Model Driven Architecture approach to system development [23] effectively assumes that a notation needs to be open to extension and specialisation. The need for architects to share a model, and for this model to evolve, immediately introduces the realisation that for most of its life the architecture description will be incomplete and probably inconsistent. Looking for inconsistencies in the architecture description is the principal means of validating it early in its life [24,25,26,12,27]. The research reported here builds on those ideas. In particular, like others, we take an approach to architecture description based on relational models [11,24]. We capture the details of an architectural description in UML or SysML, but support this with a precise specialised metamodel that has been expressed relationally. This means that we can capture the consistency constraints very precisely in relational algebra [28,29] and formally validate the metamodel as we develop the architecture description. The consequences for the research reported here are that we have a method of capturing an architectural metamodel, of capturing an architecture according to this metamodel in UML and a means of presenting that architecture for consistency checking throughout its life. We claim that this method (and our tool) supports component reuse, incremental development and collaborative working, for which we will give evidence in a later section. In order to describe the method, we begin with an example of architecture description based on UML Component diagrams.
Consistency Checking for Component Reuse in Open Systems
3
IA P
IA IB
IB
A
B IC
IC
Fig. 1. A consistent structure
3 Components and Interfaces Large scale Open Systems benefit from having their architecture described using Component diagrams in UML. These diagrams use Components to denote units of functionality and they use Interfaces to show how these units are plugged together to form assemblies with greater functionality. Components often denote quite substantial units of functionality (such as web servers, database servers etc.). Moreover, in large Open Systems there will often be dozens or hundreds of these replaceable components of various sizes and in many versions. Figure 1 shows a (simplified) Component diagram in which we see that Component P has nested within it two further components A and B. Strictly speaking, because it shows nesting, this is actually an example of a UML 2.0 Composite Structure diagram [9], where that diagram has been specialised to show nesting of Components. The interfaces in Figure 1 are shown by the ball-and-socket notation. For example Component A shows that it requires an Interface IB by its use of a socket with that label. Fortunately, also nested within Component P is a Component B which supplies such an interface, shown by the ball with that label. Normally, in a UML 2.0 diagram, this association between requires and supplies would be shown by an arrow from one to the other. Rather than do that here, since our diagrams are so simple, we have relied upon the reader’s ability to associate the two Components through their reference to an Interface by name. We see that all the components in Figure 1 supply or require interfaces. Normally, a component will both require and supply many interfaces, not just one of each as shown in this simple example. We say that the example in Figure 1 is consistent because all of the interface requirements are satisfied. The fact that Component B requires Interface IC is satisfied by this being brought to the outside and shown as a required interface on the parent P. Similarly, that Component P supplies Interface IA is satisfied by the fact that it contains a nested Component A which is the source of this interface. In contrast Figure 2 shows an inconsistent Component diagram. This time Component Q contains Components A and D which leads to some mismatches. Most obviously, we see that Component A, in this context, does not have its requirement for Interface IB satisfied, because there is no sibling that supplies that interface, nor has it been brought to the outside and made a required interface of the parent Q. We refer to this missing connection as dangling requires. We say that, within Component Q there is a danglingrequirement for Interface IB.
4
P. Henderson and M.J. Henderson IX
IA
Q
IA ID
IB
A
D IC
IC
Fig. 2. An inconsistent structure
Moreover Figure 2 shows an example of what we will call a dangling supplies. This is because Component Q supplies Interface IX but that is not one of the available interfaces supplied by one of its nested members. Again, note that this is a consistency constraint which is specialised from the metamodel that we are adopting and this will be explained later. Further, while we say that Component Q has a dangling-supplies of Interface IX, we do not consider the unused Interface ID of Component D to be a problem (again, a decision of the specialised metamodel). So far, what we have presented is an example of the type of Architecture Description that we advocate. It is based on a metamodel that we will introduce in a little while. The metamodel determines what types of entities will be described (here Components and Interfaces) and the consistency constraints that they must satisfy. In general, the metamodel will be defined by the Systems Architects for the specific system being designed and may use quite different entities and/or consistency constraints. We will discuss other metamodels later but first we will show how this one is formalised.
4 Specialised Metamodels Consider the way in which components and interfaces are conventionally described in a design notation such as UML or in a programming language such as Java or Python. A component will normally supply a number of interfaces and also make use of a number of interfaces supplied by other components. Figure 3 shows the entities and relations introduced by this description. It is the beginning of the metamodel against which we will check our system descriptions. The rest of the metamodel comprises the consistency constraints among these entities. Of course, this simple metamodel also needs to be extended with additional entities to be sufficiently useful in practice and these entities in turn will require further constraints. We will formalise the constraints that a correct design must obey in terms of the basic relations shown on the metamodel diagram. We denote the (natural) join operator of two relations by a dot (as for example in Alloy [30]). It forms the relational composition of its operands. Thus, for example contains.requires
denotes a binary relation formed from the composition (join) of two existing binary relations. That is, contains.requires denotes the relationship between Components and
Consistency Checking for Component Reuse in Open Systems
5
contains supplies Component
Interface requires
Fig. 3. A metamodel
Interfaces that we would describe as “Component c contains an unnamed Component that requires Interface i” . It is worth noting at this point that this focus on the whole-relation, leads to a holistic approach to the analysis of Systems Architectures, which is something we will return to in the section on Pragmatics. It is almost always the case that our relations are manyto-many. The relational algebraic approach affords a way of “reading-off” the diagram the derived relations that will be constructed as consistency rules in our metamodel. The way in which one uses relational algebra, as we will illustrate in the next section, is to construct predicates and challenge the consistency checker to construct the set of entities that fail to pass the test.
5 Consistency and Completeness The Architecture Description technique that we advocate assumes that the System Engineer will specify a metamodel and record the design against that metamodel. The metamodel will comprise entities, relationships and constraints. This section describes two such metamodels, shown respectively in Figure 3 and Figure 4. We develop consistency constraints that, according to the System Engineer who designed these metamodels, are among those that need to be satisfied if the Architecture being described is to be consistent. We also address a notion of completeness. We will assume that during development of the Architecture Description, interim models will not be consistent. The consequence for us here is that the constraints will be specified as sets of inconsistencies. The designer’s eventual objective is to achieve a design in which these sets of inconsistencies are eliminated. This approach to design supports both incremental and cooperative working. 5.1 Dangling Requires As a first example of a consistency rule, let us define the example we discussed in an earlier section, dangling-requires. Using the relations and entities illustrated in Figure 3 we can construct the relation dr as follows dr = contains.requires - contains.supplies - requires
Here, in addition to using relation join (composition) denoted by dot, we have used set difference, denoted by minus. This expression defines a relation dr which relates Components to Interfaces. The relation contains.requires contains all pairs (c,i) with the property that c contains a Component that requires i. Similarly contains.supplies contains all pairs (c,i) with the property that c contains a Component that supplies i.
6
P. Henderson and M.J. Henderson
contains supplies Component
Interface requires
derivedFrom implements tests Requirement
TestCase
Fig. 4. An extended metamodel
Thus the difference of these two relations contains all pairs where c’s requirement for i is not satisfied internally. Finally, by then constructing the difference between this set and the relation requires, we have that dr is the relation between Components c and Interfaces i, where c contains a nested Component that requires i but where that Interface is neither supplied internally nor required by the parent. This is exactly what we meant by dangling-requires. Constructing the relation dr has two benefits. First we have accepted that during development a design will be inconsistent and have decided to derive at any point in time a set of inconsistencies that the designer will eventually wish to remove. Second, by constructing a relation, we have taken a holistic approach, addressing the whole architecture description with our analysis rather than just looking at local inconsistencies. 5.2 Dangling Supplies We described informally, earlier, what we mean by dangling supplies. Formally, in terms of our metamodel we can specify this as follows ds = dom(contains)<:supplies - contains.supplies
The operator <: is domain-restrict. The first term in the definition of ds is just the relation supplies restricted to the domain of contains, which is just the relationship between composite Components and the Interfaces they supply. By constructing the difference between this relation and contains.supplies we get ds which relates composite Components to Interfaces that they supply but which are not supplied by any of their children. Precisely what we meant by dangling-supplies when we introduced it informally, earlier. 5.3 Replacements As a final example of a consistency constraint imposed by a metamodel on an Architecture, consider the situation when our Architecture is for an Open System, where we have potentially alternative suppliers of interchangeable Components. A system is Open if its interfaces are fully defined and available for exploitation, in that alternative suppliers
Consistency Checking for Component Reuse in Open Systems
7
can produce replacement or enhanced Components that plug into slots vacated by other components. How can we determine which Components are potential replacements for others? Consider canReplace = { (c1, c2) | supplies[c2] <= supplies[c1] and requires[c1] <= requires[c2]}
As before, this is a binary relation (<= denotes subset and [] denotes relational image). It is the relationship between Components with the property that if (c1, c2) is in canReplace then c1 can replace c2, wherever it might occur, simply because it supplies all the Interfaces that c2 must supply and requires only Intefaces supplied in the location that c1 would occupy. The way that this computed relation is used in practice is when (as in Figure 2) there is a mismatch, we can use canReplace to determine possible candidates to be used in place of D. This means that we have, in this metamodel, taken a particular view of what we mean by an Interface. An entity which represents an Interface by name, effectively encodes in that name both the syntax and semantics of the Interface. This is not unusual in practice but does leave undeveloped here how unequal, but related Interfaces, are to be handled in our metamodel. This is beyond the scope of this paper. 5.4 Completeness In addition to rules for checking consistency of an architecture as it is developing, there will be many rules that specify completeness of the description. An example of such a rule for the metamodels used in this paper might be that every Component should have at least one Interface that it either requires or supplies. When constructing a constraint for completeness we will work in the same way as we have for consistency and report incompletenesses during development. For example, we might report the set of Components for which there are, as yet, no Interfaces either required or supplied. In other systems for which we have developed metamodels, the kind of completeness rules we have developed include constraints such as every Component/Requirement pair should have at least one TestCase (see, for example Figure 4) or the constraint that every entity should have at least one Documentation fragment attached to it. Reports generated of architectures in development would then include sections listing incompletenesses alongside those listing inconsistencies. The Architect’s objective would be, eventually, to eliminate these sections.
6 Pragmatic Issues The example we have developed in the paper is rather simple. In practice, Architecture Descriptions of this sort can be very large. They will normally be developed incrementally and collaboratively by a team. They will also be constrained by the fact that they are building from legacy components and/or devising a modular architecture that comprises reusable components. Tools to support this type of development process must be able to deal with the consequences of these observations.
8
P. Henderson and M.J. Henderson
6.1 Tools The WAVE tool allows its users to describe Architectures [1]. It will produce documentation based on these descriptions, including reports on the inconsistencies. A prototype implementation of WAVE is available at http://ecs.soton.ac.uk/˜ph/WAVE. It comprises a collection of scripts which transform among representations of the architecture descriptions and which support the merging of independently developed models. WAVE also supports the inclusion of specialised metamodels. The prototype assumes that descriptions made according to these models will have an XML representation. In practice, we have used WAVE as an adjunct to a UML tool (Sparx Systems Enterprise Architect) from which the architecture description can be dumped as an XMI file. This XMI description is first turned into a realtional model, capturing data from the XML according to the chosen metamodel. The consistency checking is then done by a script that computes the “inconsistency” relations such as dr, ds and canReplace as described here. A further script then constructs the documentation of the architecture including the reports on inconsistencies in that report. We plan to replace this XML based implementation with one based on a conventional relational database in the near future, in order to inherit the robustness and transactional properties of those systems. The architect will then be able to publish their incremental description and share it with others via that shared database. 6.2 Collaborative Working, Incremental Development and Component Reuse The architects work by capturing new parts of the description and then using the tool to generate interim documentation. The inconsistencies are highlighted. So they continue to develop, all the while trying to remove inconsistencies they have added. Collaborative working is supported because the architects can work independently as follows. Each publishes their models to the others. When running consistency checking, each architect can merge their work with the work of others. The generated interim documentation contains inconsistencies that are now across the whole architecture. It will be apparent to each architect which inconsistencies are their responsibilities. They continue to work on their independent parts, while following this process of incremental development. Where the architecture is something being developed around a catalogue of reusable components (which is the norm these days) then the component descriptions can be held with the component in such a way that integrating them into a new “build” (i.e. build of the architecture) is straightforward. Thus the plug-and-play that is afforded by component reusability at the implementation stage is mirrored at the design stage by having reusable component-descriptions.
7 Conclusions We contend that architecture description is an important problem for Information Systems development, especially for large Open Systems with many architects, many engineers and many legacy components.
Consistency Checking for Component Reuse in Open Systems
9
We have observed that such an architecture description is likely to be incomplete and inconsistent for much of its life. We have argued that capturing the architecture description according to a precise specialised metamodel introduces the kind of redundancy in description that allows inconsistencies to be detected early in the life of an architecture description. We have given examples of the kinds of metamodels that can be developed. We have described tools based on UML that allow a pragmatic approach to developing both metamodels and architecture descriptions that are compliant to those metamodels. The particular example we have chosen to illustrate the method used Components and Interfaces, which are particularly appropriate in the context of component reuse. We have shown how the method lends itself to reuse of component descriptions, as well as to reuse of components. In the future, we will refine our methods and tools in particular ways, not least in integrating the architecture description with its documentation based on narrative structure [27]. We plan to publish detailed metamodels that we have developed along with collaborators. We recognise that many of the more complex consistency constraints that we specify have analogues in graph algorithms and wish to pursue this potentially rich theme. In particular, it might allow us to investigate the kinds of architectural complexity that Alexander described in the 60s and then deprecated in the 70s [31] or put more flesh on the bones of interesting new developments such as the Algebra of Systems [26]. The method we have presented is now quite mature and is being applied in practice by our industrial collaborators. The tool is usable and integrates well with established tools. We believe that the method and tools together constitute a sound and practical method of enhancing architecture description.
References 1. Henderson, P., Henderson, M.J.: Collaborative development of system architecture - a tool for coping with inconsistency. In: 21st International Conference on Software Engineering and Knowledge Engineering (SEKE 2009). Knowledge Systems Institute, Skokie (2009) 2. Kruchten, P.: Architectural Blueprints - the 4+1 view model of software architecture. IEEE Software 12(6), 42–50 (1995) 3. Shaw, M., Garlan, D.: Software Architecture - Perspectives on an emerging discipline. Addison-Wesley, Upper Saddle River (1996) 4. Maier, M.W., Rechtin, E.: The Art of System Architecting, 2nd edn. CRC Press LLC, Boca Raton (2002) 5. Henderson, P.: Laws for dynamic systems. In: International Conference on Software Re-Use (ICSR 1998). IEEE, Los Alamitos (1998) 6. Henderson, P., Yang, J.: Reusable web services. In: 8th International Conference on Software Reuse (ICSR 2004). IEEE, Los Alamitos (2004) 7. Rozanski, N., Woods, E.: Software Systems Architecture. Addison-Wesley, Upper Saddle River (2005) 8. Shaw, M., Clements, P.: The golden age of software architecture. Software, 31–39 (March/April 2006) 9. OMG: Unified Modeling Language, superstructure (2007),http://www.uml.org 10. OMG: OMG Systems Modeling Language (2006), http://www.uml.org
10
P. Henderson and M.J. Henderson
11. Holt, R.C.: Binary relational algebra applied to software architecture. In: CSRI Technical Report 345. University of Toronto (1996) 12. Hadar, E., Hadar, I.: Effective preparation for design review - using UML arrow checklist leveraged on the guru’s knowledge. In: OOPSLA. ACM, New York (2007) 13. Balasubramanian, K., Balasubramanian, J., Parsons, J., Gokhale, A., Schmidt, D.C.: A platform independent component modeling language for distributed real-time and embedded systems. J. Comput. Syst. Sci. 73(2), 171–185 (2007) 14. Dekel, U., Herbsleb, J.D.: Notation and representation in collaborative object-oriented design: an observational study. In: SIGPLAN Notices, vol. 42(10). ACM, New York (2007) 15. Egyed, A.: UML/analyzer: A tool for the instant consistency checking of UML models. In: ICSE 2007: Proceedings of the 29th international conference on Software engineering. ACM, New York (2007) 16. Nejati, S., Sabetzadeh, M., Chechik, M., Easterbrook, S., Zave, P.: Matching and merging of statecharts specifications. In: 29th International Conference on Software Engineering (ICSE 2007), pp. 54–64 (2007) 17. Balzer, B.: Tolerating inconsistency. In: ICSE 1991: Proceedings of the 13th international conference on Software engineering. ACM, New York (1991) 18. Egyed, A.: Instant consistency checking for the UML. In: ICSE 2006: Proceedings of the 28th international conference on Software engineering, pp. 381–390. ACM, New York (2006) 19. Egyed, A.: Fixing inconsistencies in UML design models. In: ICSE 2007: Proceedings of the 29th international conference on Software engineering. ACM, New York (2007) 20. Sabetzadeh, M., Nejati, S., Liaskos, S., Easterbrook, S., Chechik, M.: Consistency checking of conceptual models via model merging. In: RE, pp. 221–230 (2007) 21. Sabetzadeh, M., Nejati, S., Easterbrook, S., Chechik, M.: Global consistency checking of distributed models with tremer. In: 30th International Conference on Software Engineering (ICSE 2008), Formal Research Demonstration (2008) (to appear) 22. Nuseibeh, B., Easterbrook, S., Russo, A.: Making inconsistency respectable in software development. Journal of Systems and Software 58, 171–180 (2001) 23. OMG: MDA guide (2003), http://www.uml.org 24. Beyer, D., Noack, A., Lewerenz, C.: Efficient relational calculation for software analysis. Transactions on Software Engineering 31(2), 137–149 (2005) 25. Chang, K.N.: Consistency checks on UML diagrams. In: International Conference on Software Engineering Research and Practice, SERP 2007. IEEE, Los Alamitos (2007) 26. Koo, B.H.Y., Simmons, W.L., Crawley, E.F.: Algebra of systems: An executable framework for model synthesis and evaluation. In: Proceedings of the 2007 International Conference on Systems Engineering and Modeling. IEEE, Los Alamitos (2007) 27. Henderson, P., de Silva, N.: System architecture induces document architecture. In: 20th International Conference on Software Engineering and Knowledge Engineering (SEKE 2008). IEEE, Los Alamitos (2008) 28. Date, C.: Database in Depth - Relational Theory for Practitioners. O’Reilly Media Inc., Sebastopol (2006) 29. Beyer, D.: Relational programming with CrocoPat. In: ICSE. IEEE, Los Alamitos (2006) 30. Jackson, D.: Software Abstraction. MIT Press, Cambridge (2006) 31. Alexander, C.: Notes on the Synthesis of Form (with 1971 preface). Harvard University Press, Cambridge (1964)
Generating Verified Java Components through RESOLVE Hampton Smith1, Heather Harton1, David Frazier2, Raghuveer Mohan1, and Murali Sitaraman1 2
1 School of Computing, Clemson University, Clemson, SC 29634, USA Computer Science Department, East Tennessee State University, Johnson City, TN 37614, USA {hamptos,hkeown,rmohan,murali}@cs.clemson.edu,
[email protected]
Abstract. For software components to be reused with confidence, they must be correct. Unlike testing, formal verification can be used to certify that a component will behave correctly regardless of context, as long as that context satisfies component assumptions. Some verification systems for developing correct components in languages such as Java are simplified to be practical, but are not complete. Other systems that account for necessary semantic complications arising from underlying reference behavior demand non-trivial specification and verification. This paper describes an alternative. Under this approach, reusable components are specified, implemented, and verified in RESOLVE, a language with clean semantics, and are translated to Java. To improve confidence in the verification process, we are currently re-engineering the RESOLVE verification system itself with generated verified components.
1 Introduction A fundamental goal of modern object oriented programming is to improve software engineering through the development and assembly of reusable software components. However, precisely that which is the greatest strength of object orientation—reuse— increases the necessity for verifying components. If the details of a component are to be kept hidden, and its behavior abstracted, then the client must be able to have confidence that the component works as described [1]. As a result, the push to apply formal methods to specify and verify both programs and properties of programs continues to accelerate, not just for mission-critical software but for reusable components in general. Several of these efforts have focused on extending existing programming languages with formal specifications. Examples of this are Spec# for C# [2] and JML for Java [3]. Unfortunately, popular objectoriented languages contain features that make formal verification difficult [4]. These difficulties can be formalized in the notion of clean semantics [5]. A language has clean semantics if it 1) allows for a state space defined only by named variables that represent mathematically rich values, and 2) allows code to affect the values of only those variables explicitly named. When the semantics of a language are clean, specifying components is more straightforward and thus verification is easier. RESOLVE S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 11–20, 2009. © Springer-Verlag Berlin Heidelberg 2009
12
H. Smith et al.
[6] is an integrated specification and implementation language that has been designed to have clean semantics. At ICSR 2000 [1], we explained that, in principle, it is possible to specify and verify software components in a modular fashion. An operation to reverse a List component was used as an example. Since then, we have built the RESOLVE Verifying Compiler [7, 8], which is able to perform mechanical verification and generate code for a class of programs, including the example in [1]. The compiler allows users to generate verified Java components by developing and verifying components in RESOLVE, then generating Java code from verified RESOLVE software. When used alongside unverified Java code, these verified components can increase the confidence in the overall system and narrow the search for bugs to unverified code. Because the compiler itself ultimately needs to be trustworthy, we take a step toward this goal by exploring a re-engineering case study in which correctby-construction Java components are incorporated into the RESOLVE verifying compiler itself. The paper is organized as follows. In section 2 we compare and contrast our method with related efforts for achieving verified Java components. In section 3, we give an overview of the RESOLVE compiler and how it can be used to generate reusable, verified Java components. In section 4, we present a case study in which we replace an existing Java component with a verified one. In section 5 we will present challenges, our conclusions, and some thoughts for future work.
2 Approaches for Verified Java Components This section contains a summary of related work in developing correct Java components. 2.1 Jahob Jahob verifies programs written in a subset of the Java programming language using Isabelle as a specification language [9]. Jahob's goal is to to provide static verification and guard against a class of errors, rather than to provide a mechanism for full functional verification. Jahob uses shape analysis to assist in automatically determining invariants [10, 11]. 2.2 ESC/Java ESC/Java uses a series of static checks to attempt to identify such run-time errors as unhandled exceptions, incorrectly-used locks, and accesses outside of the bounds of an array [12]. The VCs generated by ESC/Java are passed to the automated prover Simplify [13]. The specification language used by ESC/Java has been developed in conjunction with JML [14] and is very similar. The next generation of ESC/Java, ESC/Java2, is used to perform static checks for JML [15]. In addition to ESC, there are other JML Static Verification Tools [16, 17, 17, 19]. ESC/Java discourages aliasing. JML, however, uses a model that only allows the “owner” of an object to modify the object. These approaches limit the developer to a subset of Java. In addition, as noted in [20], JML has yet to catch up to developments in the Java programming added in Java 1.5, such as generics and enums.
Generating Verified Java Components through RESOLVE
13
2.3 Why The system Why provides a mechanism to verify C, ML, and Java programs. The programs are converted into a Why Internal language which is similar to ML [21]. As an example, Java programs annotated in JML are translated into Why by a program called Krakatoa. Krakatoa therefore represents another verification system for Java programs with JML specs [18]. Why generates VCs for various existing proof tools including Coq, PVS, Mizar, and HOL Light. Why also uses the Simplify [13] and haRVey [22] decision procedures to perform proofs. In general, Why disallows aliasing; however, Krakatoa models the Java heap so that once converted to Why, there is no aliasing. However, there are still portions of Java not handled by Krakatoa [18].
3 Verified Java Component Generation 3.1 Input Components The input to the RESOLVE verifying compiler consists of specifications in the RESOLVE integrated specification language and code in the RESOLVE programming language. In Figure 1, we see part of the List component defined in a concept called List_Template. RESOLVE concepts are specified by modeling objects using a variety of mathematical entities, such as numbers, strings, sets, and functions. In List_Template, to capture ordered collections of elements in which there is a cursor marking the insertion position, a List is modeled as an ordered pair of mathematical Concept List_Template(type Entry); uses Std_Integer_Fac, String_Theory; Family List is modeled by Cart_Prod Prec, Rem: Str(Entry); end; exemplar P: List; initialization ensures P.Prec = empty_string and P.Rem = empty_string; Operation Advance_to_End(update P: List); ensures P.Prec = #P.Prec o #P.Rem and P.Rem = empty_string; Operation Insert(clears New_Entry: Entry; updates P: List); ensures P.Prec = #P.Prec and P.Rem = <#New_Entry> o #P.Rem; Operation Remove(replace Entry_Removed: Entry; update P: List); requires P.Rem /= empty_string; ensures P.Prec = #P.Prec and #P.Rem = <Entry_Removed> o P.Rem; (* Other operations omitted for brevity *) end List_Template;
Fig. 1. A part of the List_Template specification
14
H. Smith et al.
strings: the elements in the first string precede the cursor (to the left of the cursor using the terminology of [1]), and those in the second string remain, following the cursor (to the right). The use of mathematical entities allows for a formal conceptualization of programming objects without referring to object implementation details. Stacks, Queues, Lists, and other objects that represent ordered collections can all be modeled mathematically using strings and may thus avail themselves of associated notations and theorems from mathematical string theory. Reuse of theories allows for the effort invested in establishing various theorems to be reused [23]. As an example for explaining verification, consider the Reverse operation on List proposed in [1], for which both a specification and realization are given in figure 2. The function rev in the specification is a mathematical operator that reverses a string, and |X| is a notation for the length of a string X. Here, the Advance_to_End operation is used in place of the original Advance used in [1] because the replacement eased mechanical verification. Enhancement Reverse_Capability for List_Template; Operation Reverse(updates S:List); requires |S.Prec| = 0; ensures S.Prec = rev(#S.Rem) and |S.prec|; end Reverse_Capability; Realization Reverse_Realiz for Reverse_Capability of List_Template; Procedure Reverse(updates S:List); decreasing |S.Rem|; Var temp: Entry; if Length_of_Rem (S) > 0 then Remove(temp, S); Reverse(S); Insert(temp, S); Advance_to_End(S); end; end Reverse; end Reverse_Realiz;
Fig. 2. Specification and realization of List Reverse_Capability
3.2 Verification Output In order to verify a component correct, the RESOLVE compiler first generates a series of logical implications called verification conditions or VCs. These VCs are generated such that proving them is necessary and sufficient to demonstrate that the program is correct. To verify the code in Figure 2, VCs must be generated for the preconditions of each operation (e.g., Advance requires that the remaining string of a List not be empty), for the implementation itself (to guarantee that it meets the ensures clause of the specification for Reverse), and for the progress metric, which states that the length of S.Rem must decrease with each recursive call in order to terminate. The VCs produced by the compiler can be output in the syntax accepted by the Isabelle proof assistant, in a more user-friendly syntax for human inspection, or passed
Generating Verified Java Components through RESOLVE
15
directly to RESOLVE's integrated prover. As an example, the code in Figure 2 generates seven different VCs intended to guarantee both functional correctness and termination. The integrated RESOLVE Prover is able to dispatch each. However, for more complicated code, the generated VCs are often outside the reach of either Isabelle or the RESOLVE integrated prover. Exploring techniques for writing more easily-provable code, generating more straightforward VCs, and proving resulting VCs are active areas of our research. 3.3 Output Java Components For the given example, the compiler generates Java code for List_Template, its implementation, the Reverse enhancement, and the Reverse implementation. A snippet of the generated code for the Reverse implementation is shown in Figure 3. This code can be compiled and used to extend Java List components compiled from RESOLVE implementations of the List_Template specification [24]. Since the source RESOLVE code has been verified correct, the generated Java code is correct by construction, insofar as the verification and translation processes can be trusted. Increasing the trustworthiness of the verification process is discussed in Section 4. 3.4 Challenges Because RESOLVE is imperative and object oriented, the process of writing RESOLVE code should be straightforward to programmers familiar with languages like Java. However, because RESOLVE is designed to be suitable for verification, it has some requirements that are likely to be unfamiliar to such programmers. Specifically, many programmers will be unfamiliar with writing formal specifications for methods and annotating loops with invariants. However, we have data from our experience teaching RESOLVE to undergraduate students that suggests this transition is fairly straightforward. This data is the topic of [25, 26, 27]. public class Reverse_Realiz implements Reverse_Capability, List_Template, InvocationHandler { public void Reverse(List_Template.List S) { RType temp = getTypeEntry().initialValue(); if (((Std_Boolean_Realiz.Boolean) (Std_Integer_Fac.Greater(Length_of_Rem(S), Std_Integer_Fac.createInteger(0)))).val) { Remove(temp, S); Reverse(S); Insert(temp, S); Advance(S); } } /* Much omitted for brevity */ }
Fig. 3. Snippet of Java code generated from RESOLVE implementation of Reverse
16
H. Smith et al.
4 Re-engineering the Verifying Compiler A faulty verification tool may assert that a component is correct with respect to its specification even when it is not. One important method for achieving this is, of course, to encourage the use of existing, mature components in our verification tools. A discussion of mature Java runtime component usage in the RESOLVE verifying compiler is the topic of section 4.1. Another option is to begin with a tool implemented using well-specified components that have not been verified, but in which our confidence is high due to their maturity, then to gradually replace these components with equivalent ones verified and generated by the tool itself. As we re-engineer our tool in this way, we increase our confidence that the tool is sound. Clearly, a faulty tool may verify and generate faulty components, but each re-engineering iteration is a new chance to reverify components under a new, and presumably better, set of circumstances, as well as a new opportunity to test these components and expose problems. While the ultimate goal is a system (in this case, a compiler) constructed of 100% verified code, in this paper we seek to establish that using verified libraries is a tenable next step in software engineering, where mature, vetted libraries are already used as a method to increase confidence that overall systems are correct. The application of these ideas to the RESOLVE verifying compiler is the topic of section 4.2. 4.1 Summary of Reusable Component Usage in the Current Compiler The RESOLVE Verifying Compiler uses many mature components, such as those found in the Java runtime library. We have identified which components from the Java runtime are used most frequently. These components are prime candidates for being replaced with verified components. The results of this investigation are found in Table 1. Counts of the String Java component have been omitted as being, if nothing else, fairly boring. Since the List component appears so often, it is an excellent candidate for being replaced with a verified alternative. Table 1. Instances of three often-used Java runtime components in the RESOLVE Verifying Compiler
List
StringBuffer
Map
Analyzer
145
0
0
Translator
181
103
10
VCGenerator
201
12
1
4.2 Re-engineering Issues Because of differences in the way RESOLVE and Java represent objects, care must be taken when designing the interfaces of components that are to be re-engineered. For instance, RESOLVE's primary mechanism for moving an object is to swap it with another object, as opposed to Java-style reference assignment. As a result,
Generating Verified Java Components through RESOLVE
17
RESOLVE components, when translated to Java, implement a special interface that provides methods called getRep() and setRep(), which essentially allow the data associated with a particular object (its representation) to be retrieved and set in a wholesale manner. This means that not only do components such as List need to implement these methods from the start if they are to be re-engineered, but also those components that will be inserted into the List. This restriction only applies to classes that are an explicit part of the public interface of the component. To facilitate such an interface, we created a simple wrapper class that allows arbitrary Java objects to be wrapped into a type acceptable to RESOLVE components. Using this class, we inserted a RESOLVE implementation of the List component into RESOLVE's integrated prover. It should be noted that while we are able to verify certain operations on Lists, we are not yet able to perform full mechanical verification on an implementation of List. However, since translation is independent of verification, we may integrate the component first and fully verify it later. In Figure 4. we present a snippet of code before and after the new component was added. pastStates was originally a Java doubly-linked list, being used here as a stack. It has been replaced in this example with a List generated from RESOLVE code. The List used here is a bounded version of the one presented in Section 3. That is, it has a maximum capacity. The unbounded version was presented to be consistent with the example in [1]. Because RESOLVE uses swapping to pass objects, inserting the contents of workingRESOLVEObject requires that another valid object fill the representation of that variable. Thus workingRESOLVEObject remains a valid, non-null RESOLVE object that does not cause an alias with the data stored in pastStates. /* Code before */ pastStates.push(vC); attemptStep(vC, curLength, metrics, pastStates); pastStates.pop(); /* Code after */ Rtype workingRESOLVEObject = new RtypeWrapper(vC); One_Way_List_Facility.Insert(workingRESOLVEObject, pastStates); attemptStep(vC, curLength, metrics, pastStates); One_Way_List_Facility.Remove(workingRESOLVEObject, pastStates);
Fig. 4. Snippet from the integrated prover before and after re-engineering
With the wrapper class, replacing a Java component with a more readily verifiable reusable component is straightforward. However, one issue we encountered is that the translation into Java was originally implemented under the assumption that the source code would represent a full RESOLVE program, rather than a component that might be mixed with existing Java code. As a result, the getRep() and setRep() functions each manipulate Java objects of type Object and thus provide no typesafety. Indeed, while the RESOLVE List must be parameterized with a RESOLVE type when it is initialized, our wrapper class would subsequently allow Java objects of any kind to be inserted, and this could cause a verified component to fail when it attempts to manipulate an internal object of an unexpected type. An obvious solution to this would be to allow the RType interface to be parameterized by a Java generic so
18
H. Smith et al.
that getRep() and setRep() operate on objects of the appropriate type. We intend to modify the translation system to allow for type-safe integration of generated components into Java code.
5 Conclusions Programming languages that are designed with verification of object-based software in mind, such as the RESOLVE, enable software engineers to create verified reusable components even in languages that are not designed to facilitate verification, such as Java. With this technique, a library of verified components can be generated in any language and used alongside components that have not been formally verified. With care, the interfaces to hand-written components in such a language can be designed such that they can be replaced at a later date with equivalent verified components. This technique can be applied to the verification tools themselves to increase our confidence in them. This paper presents a case study in which we have applied these techniques to the RESOLVE verifying compiler. While our example of a List component in this paper was chosen for its simplicity, the intention is that larger, more richly featured components will be written and verified in RESOLVE to be used alongside mature Java components. Obstacles remain to the development of a library of verified, reusable components. Development of the verifying compiler, both in terms of the understanding necessary to automate the process fully and in terms of implementation, requires considerable additional research. In addition, the translation process itself cannot be verified until adequate formalisms to specify, develop, and verify components for compilation and verification are conceived. Even as these long-term problems remain, this paper identifies a way to generate trustworthy components in languages such as Java in the short term starting with RESOLVE.
Acknowledgments This research is funded in part by NSF grants CCF-0811748 and DMS-0701187. We thank the members of the RESOLVE/Reusable Software Research Group (RSRG) at Clemson and Ohio State for discussions on the topics presented in this paper.
References 1. Sitaraman, M., Atkinson, S., Kulczycki, G., Weide, B.W., Long, T.J., Bucci, P., Heym, W.D., Pike, S.M., Hollingsworth, J.E.: Reasoning about software-component behavior. In: Frakes, W.B. (ed.) ICSR 2000. LNCS, vol. 1844, pp. 266–283. Springer, Heidelberg (2000) 2. Barnett, M., Leino, K.R., Schulte, W.: The Spec# Programming System: An Overview. In: Barthe, G., Burdy, L., Huisman, M., Lanet, J.-L., Muntean, T. (eds.) CASSIS 2004. LNCS, vol. 3362, pp. 49–69. Springer, Heidelberg (2005) 3. Burdy, L., Cheon, Y., Cok, D., Ernst, M., Kiniry, J., Leavens, G.T., Leino, K.R.M., Poll, E.: An overview of JML tools and applications. STTT 7(3), 212–232 (2005)
Generating Verified Java Components through RESOLVE
19
4. Weide, B.W., Heym, W.D.: Specification and Verification with References. In: Proc. SAVCBS, pp. 50–59 (2001) 5. Kulczycki, G.: Direct Reasoning, Ph. D. Dissertation, Clemson University (2004) 6. Edwards, S.H., Heym, W.D., Long, T.J., Sitaraman, M., Weide, B.W.: Part II: specifying components in RESOLVE. SIGSOFT Softw. Eng. Notes 19(4), 29–39 (1994) 7. Harton, H.K., Sitaraman, M., Krone, J.: Formal Program Verification. In: Wah, B. (ed.) Wiley Encyclopedia of Computer Science and Engineering, John Wiley & Sons, Chichester (2008) 8. Sitaraman, M., Adcock, B., Avigad, J., Bronish, D., Bucci, P., Frazier, D., Friedman, H.M., Harton, H., Heym, W., Kirschenbaum, J., Krone, J., Smith, H., Weide, B.W.: Building a Push-Button RESOLVE Verifier: Progress and Challenges. Technical Report RSRG09-01, School of Computing, Clemson University, Clemson, SC (2009) 9. Kuncak, K., Rinard, M.: An Overview of the Jahob Analysis System: Project Goals and Current Status. In: Proceedings 20th IEEE International Parallel & Distributed Processing Symposium, p. 323 (2006) 10. Wies, T.: Symbolic Shape Analysis. Master’s thesis, Universität des Saarlandes, Saarbrücken, Germany (September 2004) 11. Wies, T., Kuncak, V., Lam, P., Podelski, A., Rinard, M.: Field Constraint Analysis. In: Proc. Int. Conf. Verification, Model Checking, and Abstract Interpratation (2006) 12. Flanagan, C., Leino, K.R.M., Lillibridge, M., Nelson, G., Saxe, J.B., Stata, R.: Extended Static Checking for Java. In: Proc. ACM SIGPLAN 2002 Conference on Programming language Design and Implementation. Berlin, pp. 234–245 (2002) 13. Detlefs, D., Nelson, G., Saxe, J.B.: Simplify: A Theorem Prover for Program Checking. J. ACM 52(3), 365–473 (2005) 14. Leavens, G.T., Baker, A.L., Ruby, C.: Preliminary Design of JML: A Behavioral Interface Specification Language for Java. ACM Software Engineering Notes 31, 1–38 (2006) 15. Poll, E., Kiniry, J., Cok, D.: Introduction to JML, http://secure.ucd.ie/products/opensource/ESCJava2/ESCTools/ papers/CASSIS2004.pdf 16. Burdy, L., Requet, A., Lanet, J.: Java applet correctness: A developer-oriented approach. In: Araki, K., Gnesi, S., Mandrioli, D. (eds.) FME 2003. LNCS, vol. 2805, pp. 422–439. Springer, Heidelberg (2003) 17. Ahrendt, W., Baar, T.H., Beckert, B., Bubel, R., Giese, M., Hähnle, R., Menzel, W., Mostowski, W., Roth, A., Schlager, A., Schmitt, P.H.: The KeY tool. Software and System Modeling 4, 32–54 (2005) 18. Marché, C., Paulin-Mohring, C., Urbain, X.: The Krakatoa Tool for Certification of Java/JavaCard Programs Annotated in JML. Journal of Logic and Algebraic Programming 58(1-2), 89–106 (2004) 19. Chalin, P., James, P.R., Karabotsos, G.: JML4: Towards an Industrial Grade IVE for Java and Next Generation Research Platform for JML. In: Shankar, N., Woodcock, J. (eds.) VSTTE 2008. LNCS, vol. 5295, pp. 70–83. Springer, Heidelberg (2008) 20. Cok, D.: Adapting JML to generic types and Java 1.6. In: Proc. SAVCBS, pp. 27–35 (2008) 21. Filliâtre, J., Marché, C.: The Why/Krakatoa/Caduceus Platform for Deductive Program Verification. In: Werner, D., Holger, H. (eds.) CAV 19. LNCS, vol. 4510. Springer, Berlin (2007) 22. Ranise, S., Deharbe, D.: The haRVey decision procedure, http://www.loria.fr/~ranise/haRVey/
20
H. Smith et al.
23. Smith, H., Roche, K., Sitaraman, M., Krone, J., Ogden, W.F.: Integrating math units and proof checking for specification and verification. In: Proc. SAVCBS, pp. 59–66 (2008) 24. Hunt, J.M., Sitaraman, M.: Enhancements - Enabling Flexible Feature and Implementation Selection. In: Bosch, J., Krueger, C. (eds.) ICOIN 2004 and ICSR 2004. LNCS, vol. 3107, pp. 86–100. Springer, Heidelberg (2004) 25. Leonard, D., Hallstrom, J., Sitaraman, M.: Injecting Rapid Feedback and Collaborative Reasoning in Teaching Specifications. In: Proc. ACM SIGCSE 2009 (2009) 26. Long, T.J., Weide, B.W., Bucci, P., Gibson, D.S., Sitaraman, M., Hollingsworth, J.E., Edwards, S.H.: Providing Intellectual Focus To CS1/CS2. In: Proc. 29th SIGCSE Technical Symposium on Computer Science Education, pp. 252–256. ACM Press, New York (2009) 27. Sitaraman, M., Long, T.J., Weide, B.W., Harner, J., Wang, C.: A Formal Approach to Component-Based Software Engineering: Education and Evaluation. In: Proc. ICSR 2001, pp. 601–609. IEEE, Los Alamitos (2001)
Increasing Reuse in Component Models through Genericity Julien Bigot1 and Christian P´erez2 1
LIP/INSA Rennes 2 LIP/INRIA {julien.bigot,christian.perez}@inria.fr
Abstract. A current limitation to component reusability is that component models target to describe a deployed assembly and thus bind the behavior of a component to the data-types it manipulates. This paper studies the feasibility of supporting genericity within component models, including component and port types. The proposed approach works by extending the meta-model of an existing component model. It is applied to the SCA component model; a working prototype shows its feasibility.
1
Introduction
Component based software engineering is a very interesting approach to increase code reusability. Component models are used in a variety of domains such as embedded systems (Fractal [1]), distributed computing (CCM [2], SCA [3]), and even high performance computing (CCA [4]). There is however usually a direct mapping between component instances and execution resources as well as between components and the data-types they manipulate. This means that a component implementation binds together three distinct concerns: the behavior of the component, the data-types it manipulates and the execution resources it is targeted to. Separating those three concerns would greatly increase reusability as each aspect could be selected independently to be combined latter. While there are some works on automatic mapping of components on resources, there are few works on abstracting component models similarly as what is addressed by generic programming where algorithms and data-types can be parameters. This paper presents an attempt to support genericity in component models in order to validate the feasibility of this idea and evaluate its advantages on an example. This is achieved by extending an existing component model (SCA) with concepts to support genericity and by implementing a tool that transforms applications written in this extended model back to the original one. The remainder of this paper is organized as follow. Section 2 describes an example of component that would benefit from the introduction of genericity. Section 3 analyzes some related works. An approach to introduce genericity is described in Section 4 and applied to SCA in Section 5. Then, Section 6 evaluates how this generic SCA can be used to implement the example described earlier through a prototype. Finally, Section 7 concludes and present some future works. S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 21–30, 2009. c Springer-Verlag Berlin Heidelberg 2009
22
2
J. Bigot and C. P´erez
A Motivating Example: The Task Farm
Algorithmic skeletons are constructs that describe the structure of recurring composition patterns [5]. Some skeletons have been identified for the case of parallel computing, such as the pipeline (computation in stages), the task farm (embarrassingly parallel computations), the map and reduce (data parallel apply to all and sum up computations), the loop (determinate and indeterminate iterative computations) and the divide & conquer skeletons. As an example, the task farm skeleton shown in Fig. 1 takes a data-stream as inW put and outputs a processed version of this D W C .. stream. The parallelism is obtained by run. W ning in parallel multiple instances of workers (W in Fig. 1), each one processing a single piece of data at a time. A dispatcher (D Fig. 1. The task farm skeleton in Fig. 1) handles the input and chooses the worker for each piece of data and a collector (C in Fig. 1) reorders the outputs of the workers to generate the farm output. A typical component based implementation of the task farm will wrap each of the three roles in a component. The farm itself will be a composite containing instances of these components. To increase the reusability of this composite, it should be possible to use it for various processing applied to the data, for various types of data in the stream and for various numbers of workers. It is thus interesting to let the type of the data stream, the implementation of the workers as well as their number be parameters of the composite. When knowledge about the content of the manipulated data or about the behavior of the workers makes it possible to provide optimized implementations of the dispatcher or collector it should be possible to use these implementations. This should however not complexify the usage for cases where the default implementation is sufficient. It is thus interesting to let the implementations of these two components be parameter of the composite with some default values. Hence, the task farm is a good example of component that could benefit from the support of genericity. Kinds of needed parameters include data-values (the number of workers), data-type (data stream) and component implementations (dispatcher, worker and collector), with the possibility to provide default values.
3 3.1
Related Works Languages with Support for Genericity
Genericity [6] is ubiquitous in object-oriented languages. For example, ADA, C++, C, Eiffel and Java all support it [7]. Classes, methods and in some cases procedures can accept parameters. Parameters can be data-types or in some cases data-value constants. A typical usage is to implement type-safe containers where the type of the contained data is a parameter.
Increasing Reuse in Component Models through Genericity
23
There are two main approaches for handling the validity of parameter values. In some languages such as Java, explicit constraints on the values of parameters [8] restrict their uses in the implementation. In other languages such as C++, the uses of the parameters in the implementation restrict the values they can be bound to [9]. Explicit constraints eases the writing and debugging of applications as invalid use of generic concepts can be detected using their public interface only. Describing the minimal constraints on parameters can however prove to be a very complex task. The upcoming C++0x [10] takes a mixed approach: constraints are expressed as use patterns of the parameters (this is called “concepts” in the C++0x terminology) but this does not prevent use of parameters in the implementation that were not covered by a “concept”. In some languages such as C++, explicit specializations can be provided for specific values of the parameter. This makes it possible to provide optimized implementations for these cases. This also makes the language Turing complete and enables template meta-programming [11]. As far as we know, there is no component model with support for genericity (except for HOCs further discussed in Sec. 3.3). The closest features found in most models are configuration properties which are values that can be set to configure the behaviour of components. In some models such as CCM these configuration properties can be modified at run-time. In other models such as SCA, they can only be set in the assembly making them more similar to generic parameters. Unlike generic parameters however, properties are only used to carry data-values, not types. 3.2
Algorithmic Skeletons
As seen in the previous section, the implementation of algorithmic skeletons is an example where genericity brings great advantages. Model bringing together components and skeletons have already been described, for example in [12]. These models are very similar to a component model supporting genericity from the point of view of a user of skeletons: skeletons are instanciated and the implementation of the component it contains are passed as parameters. In these model however, skeletons are supported by keywords of the assembly language and their implementation is generated by a dedicated compiler. From the point of view of the developer of skeletons this means that supporting new skeletons or new implementations of existing skeletons requires modifications of this compiler, which can be difficult and strongly limits reusability. 3.3
Higher Order Components
Higher Order Components (HOCs) [13] is a project based on the Globus grid middleware. With HOCs, a Globus service implementation S can accept string parameters identifying other service implementations. At run-time, S can create instances of these services and use them, thus addressing the issue of reusable assembly structure. However, type consistency can not be statically checked as instantiation and use of services are deeply hidden in S implementation. Another
24
J. Bigot and C. P´erez
limitation is that only service types can be passed as parameters; data-types can not. For the task farm implementation, it leads to a distinct implementation for each data-type processed in the stream.
4 4.1
An Approach to Introduce Genericity in Component Models Overview
Introducing genericity in a component model means making some of its concepts generic. A generic concept accepts parameters and defines a family of concepts: its specializations. Each combination of parameter values of the generic concept defines one specialization. Supporting generic concepts means that when one is used, the values of its parameters must be retrieved and the correct specialization must be used. This can either be done at run-time (as has been done for C for example) or through a compilation phase (as has been done for C++ for example). The compilation approach has the advantage of requiring no modification of the run-time. It can also lead to a more efficient result since the computation of the specializations to use has already been done. On the other hand, this approach makes it impossible to dynamically instantiate specializations that were not statically used in the initial assembly. This paper studies the compilation approach: it describes a transformation that takes as input a set of generic components and that generates its non generic equivalent. The transformation is based on Model Driven Engineering (MDE). It manipulates two distinct component meta-models: B, a basic (i.e. non generic) component meta-model and G(B), the corresponding generic component metamodel. The proposed algorithm to transform instances of G(B) into semantically equivalent instances of B is presented in Section 4.3. The next section describes a pattern to derive a meta-model G(B) from a basic component model whose meta-model is B. 4.2
Genericity Pattern
As a first step, the concepts of B that will be given as parameters in G(B) and those that will accept parameters (be generic) must be chosen. An example of application of the pattern described here is shown in Fig. 2. As G(B) is an extension of B, all the elements of B belong to G(B); this section describes the additions made to the meta-model to support genericity. For each concept that can be given as a parameter (e.g. PortType in Fig. 2), a meta-class with a “name” attribute is created to model such a parameters (e.g. PortTypeParameter in Fig. 2). For each concept that is turned generic (e.g. ComponentType in Fig. 2), attributes (lines in the figure) are added to its meta-class to model its parameters. For each concept that can be given as a parameter, an additional meta-class that references a parameter and inherits from the initial concept is created
Increasing Reuse in Component Models through Genericity
25
(e.g. GenericPortType in Fig. 2). This meta-class can now be used wherever the concept given as parameter is used (e.g. Port references a PortType in Fig. 2) For each concept that can be given as a parameter, an argument meta-class is created to reference both the parameter and its value (e.g. PortTypeParameter in Fig. 2). Each meta-class that references the concept made generic (Port in Fig. 2) has an argument attribute added. These are the minimal additions to G(B) required to support genericity. Other additions not shown in Fig. 2 can however be interesting. To support default value for parameters, an attribute referencing the value must be added to parameter meta-classes. For example, the PortTypeParameter will get a PortType attribute. To support constraints on parameters values, two approaches can be used: either adding a constraint attribute to the parameter meta-classes or adding it directly to the generic meta-classes. As applying constraints to the parameter meta-classes prevents the expression of constraints that depend on more than one parameter, the second approach is chosen. A root meta-class for constraints must be added. The kind of constraints that can be expressed depend on the kind of parameters. For example for a data constant parameter, a range of values can be an interesting constraint while for an object interface, the interfaces it extends can be constrained. For each kind of constraint, a meta-class that inherits from the root meta-class must be added. In addition, meta-classes modeling the various logic combinations of other constraints must be added. To support explicit specializations, a specialization meta-class must be added for each generic concept. This meta-class has a constraint attribute that specifies in what case it must be used. It also has a copy of all attributes modeling the implementation of the generic concept. The meta-class modeling the generic concept on the other hand must have a specialization attribute added that models its explicit specializations. For example, the generic ComponentType meta-class will contain a ComponentTypeSpecialization attribute. This meta-class will contain a Constraint attribute as well as the content of the ComponentType: ports, implementation, etc. 4.3
Transformation from G(B) to B
This section describes an algorithm that transforms an application described in a generic component model into its equivalent in the basic component model. The transformation algorithm takes an instance i of G(B) (a set of meta-object ComponentInstance
*
+arguments
1
PortTypeArgument
+value
+parameter1 PortTypeParameter ComponentType
*
+parameters
+ name : string
PortType
1
+parameter
GenericPortType
Port
Fig. 2. Example of modifications to make ComponentType generic and to let PortType be given as parameter
26
J. Bigot and C. P´erez
of G(B)) as input and computes a semantically equivalent instance of B. The algorithm relies on a recursive function that takes a meta-object o of G(B) and a context c (bindings between generic parameters and their values) as input and returns a meta-object of B semantically equivalent to o. The main function of the algorithm iterates through all components of i. If a component can be instantiated in an empty context (at the root of an application), the recursive function is used to generate its equivalent in B. This equivalent is added to the output meta-model instance. The recursive function generates the equivalent of o using one of the four following behaviors depending on the kind of concept the meta-class of o models. If the modeled concept is a generic concept (such as ComponentType in Fig. 2), c is filled with the default values for parameters that have not been previously bound to a value. Then, the constraint on parameter values is checked: if it is not fulfilled, the transformation is aborted with an error. The constraints of each explicit specialization are checked. If one is fulfilled, the result of the function applied to each meta-object contained by this specialization is added to the result. Otherwise, the function is applied to the default content. If the modeled concept references a parameter (such as GenericPortType in Fig. 2), the value of this parameter is looked up in c and the application of the function to this value is returned. If there is no binding for this parameter in c, the transformation is aborted with an error. If the modeled concept references a generic concept (such as ComponentInstance in Fig. 2), a new context is created and filled with the arguments contained by o. Then, the result of the function applied to each metaobject contained by o with this new context is added to the result. If the modeled concept does not belong to any of the previous categories, the result of the function applied to each meta-object contained by o is added to the result. An instance of G(B) is valid if it conforms to the meta-model and leads to a valid instance of B when the algorithm is applied. An example of instance that conforms to the meta-model but is invalid is a composite containing (possibly transitively) an instance of itself as it may lead to infinite recursion. The recursion can be broken if the composite accepts parameters that are used in the constraints of an explicit specialization. As genericity with recursion and selection of explicit specializations is very likely to be Turing-complete, the termination problem is expected to be undecidable. C++ compilers facing the same problem fix a limit to the recursion depth after which an error is emitted.
5 5.1
Case Study: Turning SCA Generic Overview of SCA
SCA [3] (Service Component Architecture) is a component model specification. It aims at easing service oriented applications development by making possible their description as components assemblies. It defines two types of ports: services and references, both typed by an interface. Interfaces can be extracted
Increasing Reuse in Component Models through Genericity
27
from various descriptors such as a Java interface, a WSDL interface, etc. SCA also supports configuration properties as part of the external interface of SCA components. Components can have two kinds of implementations: composite implementations provided by an assembly or native implementations (such as Java or C++ classes). 5.2
A Meta-Model for Generic SCA
The pattern described in Section 4.2 has been applied to the SCA meta-model in order to create a meta-model for generic SCA. The SCA meta-model described as part of the “eclipse SCA Tools project1 ” has been used for this purpose. The concepts made generic are composites and native components, generic Java classes are supported. Parameters can be implementations, interfaces, data-types and data-values for composites, data-types and data-values for native components and Java types for Java classes. This required the addition of height additional meta-classes: GenericImplementation, ImplementationParameter, ImplementationArgument, GenericInterface, InterfaceParameter, InterfaceArgument, JavaTypeParameter and JavaTypeArgument. All the parameter meta-classes support default parameter value. No GenericJavaType meta-class has been created as Java types are simply identified by a string containing their name. No modifications have been done to support data-value parameters as SCA already has the concept of configuration properties. Support for constraints on parameter values of composites and native components has been added with a root meta-class for constraints: Constraint. As configuration properties are referenced by xpath expression in SCA XML documents, a constraint meta-class that supports boolean xpath expressions has been added: XpathConstraint. The constraints supported on other kinds of parameters are currently limited to exact equality constraints supported by the meta-classes ImplementationEqConstraint, InterfaceEqConstraint and JavaTypeEqConstraint. Three constraints that support logical combinations of other constraints have also been added:ConjonctionConstraint, DisjunctionConstraint and NegationConstraint. Support for explicit specialization of composite has been added with the addition of a compositeSpecialization meta-class which duplicates the content of the Composite meta-class. 5.3
Implementation
A prototype implementation of a generic SCA to plain SCA transformation engine has been developed. It implements the algorithm described in Section 4.3. As a special case, support for generic Java classes simply consists in checking Java type parameters for compatibility and erasing them. This is due to the fact that Java handles generics by type erasure: type parameters are used at compile-time for checking validity and then removed from the generated class file. 1
http://www.eclipse.org/stp/sca/
28
J. Bigot and C. P´erez
The meta-models of SCA and generic SCA are written in the ecore modeling language,. A first implementation attempt has been made with a Domain Specific Language (DSL) for model transformations: QVT. The support for this language for the transformation of ecore meta-models is however not satisfying yet and the algorithm has finally been coded in plain Java. Java classes corresponding to the ecore meta-classes of generic SCA have been automatically generated. Those provided as part of the eclipse SCA Tools project and corresponding to the meta-classes of plain SCA have been used. The code used to instantiate these classes by parsing generic SCA XML files and to dump them in plain SCA XML file is also automatically generated thanks to annotations in the meta-model. More than 50.000 lines of Java code have been generated; the same amount from the eclipse SCA Tools project are reused. The implementation of the transformation algorithm requires around 750 lines of Java. Most of them simply copies attributes from classes modeling concepts of generic SCA to the attribute with the same name in classes modeling plain SCA (last case of the algorithm). Those could also have been automatically generated if QVT had been used. The real logic of the algorithm only requires around 100 lines of Java; this is however only an estimation as it is mixed with the attribute copy part.
6
Generic Task Farm Component in Generic SCA
This sections examines the definition and implementation of a generic task farm in generic SCA. It aims at showing the feasibility of the approach. 6.1
Generic Farm Component
The Farm composite implements the task farm and accepts six parameters. Two Java type parameters: I and O define the type of the input and output of the farm respectively. There are three implementation parameters D, W and C that define the types of the dispatcher, workers and collector respectively; and an integer parameter N that defines the number of workers. Its implementation is shown in Fig. 3. It simply instanciates the D and C components and relies on the Replication composite further described in the next subsection to instantiate multiple instance of W. These instances are connected by data streams simulated with a generic Java interface DataPush
with a single asynchronous method void push(T data). This interface is used with I as argument before the workers and with O after. Farm Gen
in
D in dispatcher out T=I
SCA
in
Replication workers out
Gen
in
C collector
I=I, O=O, R=N, C=W
Fig. 3. The Farm composite
out
T=O
out
Increasing Reuse in Component Models through Genericity
29
The D and C parameters have default values provided: RRDispatcher and SimpleCollector that dispatch the data using a round-robbin algorithm and collect them with no reordering. These are generics Java implementations that do not depend on the data type manipulated. 6.2
Generic Replication Component
The Replication composite implements the replication of a given component and accepts four parameters. Two Java type parameters (I and O) define the type of its input and output. An implementation parameter (C) defines the type of the replicated component. An integer parameter (R) defines the number of replications. Its implementation shown in Fig. 4 relies on meta-programming and reReplication cursion. It contains one instance of C GenC called “additional” and one instance in in additional out out of Replication with the value of R When (R==1) id = R−1 decreased by one. The base case of SCAReplication GenC others the recursion is provided by an exin out in in initial out out plicit specialization used when the id = 0 R = R−1 value of R reaches one. Fig. 4. The Replication composite In the non specialized implementation of the composite, the “in” service promotes two services. This is not allowed by the SCA specification. As a workaround, a concept of multiple service has been added to generic SCA that can only be connected to a reference with multiplicity “0..n” or “1..n”. At transformation phase, instances of multiple services are replaced by multiple instances of classical services.
6.3
Evaluation
As seen in this example, the behaviour of generic assemblies relying on metaprogramming can become rather hard to analyse. It remains the duty of the component developer to describe the behaviour of such composites so that they can be used as black-boxes, exactly as in the case of primitive components. This implementation of the task farm has been used to compute pictures of the mandelbrot set. Two kinds of workers have been written and used with the generic task farm: one that computes the value of a single pixel at a time and another that computes whole tiles. Each version has been used in the farm with one, two and four workers. The transformation phase takes between one and two seconds and most of this time is spent parsing the input files. The resulting component have been succefully run using tuscany-java-1.4 on muticore hosts. The meta-model for generic SCA, the compiler and the source code for these components can be found at http://graal.ens-lyon.fr/~jbigot/genericSCA.
30
7
J. Bigot and C. P´erez
Conclusion
This paper has studied the feasibility of increasing reusability in component models thanks to genericity. To make use of existing models, a generic metamodel was derived from an existing one, and an algorithm was provided to transform generic component applications into non-generic ones. This has been applied to SCA and validated with an image rendering application based on a generic task farm component. Future works include the application of this approach to others models than SCA, the comparison of the implementation of skeletons using genericity with classical skeletons and the support for dynamic instantiation of generic components. Another interesting problem is the automatic choice of value for some parameters (for example those related to available execution resources) including the case of set of parameters interacting with each others.
References 1. Bruneton, E., Coupaye, T., Stefani, J.B.: The Fractal Component Model, version 2.0.3 draft. The ObjectWeb Consortium (February 2004) 2. Object Management Group: Common Object Request Broker Architecture Specification, Version 3.1, Part 3: CORBA Component Model (January 2008) 3. Open Service Oriented Architecture: SCA Service Component Architecture: Assembly Model Specification Version 1.00 (March 2007) 4. Allan, B.A., et al.: A Component Architecture for High-Performance Scientific Computing. International Journal of High Performance Computing Applications 20(2), 163–202 (2006) 5. Cole, M.: Bringing skeletons out of the closet: a pragmatic manifesto for skeletal parallel programming. Parallel Comput. 30(3), 389–406 (2004) 6. Musser, D.R., Stepanov, A.A.: Generic Programming. In: Gianni, P. (ed.) ISSAC 1988. LNCS, vol. 358, pp. 13–25. Springer, Heidelberg (1989) 7. Garcia, R., Jarvi, J., Lumsdaine, A., Siek, J.G., Willcock, J.: A comparative study of language support for generic programming. In: OOPSLA, pp. 115–134. ACM, New York (2003) 8. Bracha, G.: Generics in the Java Programming Language (July 2004) 9. Stroustrup, B.: The C++ Programming Language, 3rd edn. Addison-Wesley Longman Publishing Co., Boston (2000) 10. Gregor, D., J¨ arvi, J., Siek, J.G., Stroustrup, B., Reis, G.D., Lumsdaine, A.: Concepts: linguistic support for generic programming in C++. In: OOPSLA, pp. 291–310 (2006) 11. Abrahams, D., Gurtovoy, A.: C++ Template Metaprogramming: Concepts, Tools, and Techniques from Boost and Beyond. C++ in Depth Series. Addison-Wesley Professional, Reading (2004) 12. Aldinucci, M., Bouziane, H., Danelutto, M., P´erez, C.: Towards Software Component Assembly Language Enhanced with Workflows and Skeletons. In: Joint Workshop on Component-Based High Performance Computing and ComponentBased Software Engineering and Software Architecture, CBHPC/CompFrame 2008 (October 2008) 13. Gorlatch, S., D¨ unnweber, J.: From Grid Middleware to Grid Applications: Bridging the Gap with HOCs. In: Future Generation Grids. Springer, Heidelberg (2005)
Verifying Component-Based Software: Deep Mathematics or Simple Bookkeeping? Jason Kirschenbaum1 , Bruce Adcock1 , Derek Bronish1 , Hampton Smith2 , Heather Harton2 , Murali Sitaraman2 , and Bruce W. Weide1 1
The Ohio State University, Columbus OH 43210, USA {kirschen,adcockb,bronish,weide}@cse.ohio-state.edu http://www.cse.ohio-state.edu/rsrg 2 Clemson University, Clemson SC , USA {hamptos,hkeown,msitara}@clemson.edu http://www.cs.clemson.edu/~ resolve/
Abstract. Anecdotal experience constructing proofs of correctness of code built from reusable software components reveals that they tend to be relatively trivial bookkeeping exercises: they rarely require a substantive mathematical deduction. A careful empirical analysis of hundreds of verification conditions (VCs) for a library of component-client code shows the level of sophistication each proof requires, and suggests how to use the results to characterize a notion of mathematical “obviousness.”
1
Introduction
Perhaps the most powerful tool of modern programming languages—and a feature that makes new languages enticing to prospective developers—is a rich library of well-documented software components. Not only is the code in these catalogs (or “APIs” or “libraries”) reusable, but code that makes use of them tends to be reusable as well, because it builds on a cleanly-modularized foundation: programmers use components to build more specialized and sophisticated components. Thus, when considering the task of verifying the correctness of software, one logical place to begin is with verification of code that is written from the perspective of clients using these “catalog components.” Sitaraman et al. [1] have explained how to reason about and formally verify the execution-time behavior of reusable software components. The use of programming-by-contract with abstract mathematical models, along with corresponding sound proof systems, allows software developers to reason about the correctness of newly-created code that uses components. One limitation of this process, however, is its reliance on people to check the verification conditions (VCs) that result from the syntax-driven proof system. Given a human being’s propensity for error, one natural solution is to automate the reasoning process; VCs can be discharged automatically in a “push-button” manner. The verifying compiler grand challenge [2,3] is to build a compiler that both generates executable code and performs the reasoning process described above. S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 31–40, 2009. c Springer-Verlag Berlin Heidelberg 2009
32
J. Kirschenbaum et al.
This tool would give developers more confidence in the correctness of implemented software components, providing the ability to reuse software using only the contracts (or “interfaces”) of the components. One stumbling block in the path of meeting this challenge, of course, is the difficulty of fully automating mathematical theorem proving. In the general case, the problem of automatically proving or disproving a VC is undecidable [4]. We proceed on the notion that, because software engineers write code that is motivated by practical mathematical insight, real software will not normally result in VCs that are inherently undecidable. Indeed, our thesis is that most VCs generated from most programs are “obvious.” A precise definition of obvious is a long term research question that is important for software verification; we would like to be able to characterize what makes a program automatically provable. Automated provers will always require sufficient justification, as part of the program itself, to make correctness manifest. In this paper we examine VCs generated from code that builds on reusable software components, and classify them based on the reasoning methods needed for their proofs—a first step towards an eventual rigorous characterization of obviousness. This work is, to our knowledge, the first that classifies VCs in accordance with these objectives and makes a case for the simplicity—as opposed to the oft-assumed difficulty—of automatically verifying “everyday” programs. Based on our earlier work [5], we generate VCs from a battery of programs that make use of a basic component library. Of course, the results of this analysis are arguably dependent on the particular proof system and programming language used. To a lesser extent, the analysis may also be dependent on the particular components used and implementations verified, but we argue that the conclusions generalize along these dimensions—a testable thesis offered as a challenge to the community. Section 2 describes RESOLVE, the specification and programming language used in this work. In Section 3 we elaborate our taxonomy of VC classification. Section 4 presents our analysis of one example for illustration, and more general results gathered across a large component catalog. Section 4 discusses related work and Section 6 contains concluding remarks and directions for future work.
2
RESOLVE: VC Generation and an Example
The language used in this work is RESOLVE [6], an imperative language designed with fostering reusable, component-based software as the foremost objective. RESOLVE provides a catalog of abstract data type interfaces (e.g., Queue, Set, Map) on which client code can rely. The client code is written in a programmingby-contract discipline with model-based mathematical specifications, and thus adheres to a strict encapsulation boundary between abstract interface contracts and concrete implementation details: only the contracts, which formally define a component’s behavior, are necessary to write and reason about client code. More specifically, RESOLVE enforces so-called “two-level thinking”: reasoning about the correctness of a component implementation requires only the specification of that component along with the specifications of any components used
Verifying Component-Based Software
33
in the implementation. This clear delineation of roles and emphasis on mathematical formalism facilitates modular verification of RESOLVE programs via a two-stage process of (1) VC generation and (2) VC proof. The purpose of the proof system is to transform, syntactically, a RESOLVE program into a set of logical formulas whose validity is equivalent to the correctness of the program. One other major difference between RESOLVE and other languages is the use of swap, denoted by :=:, as the primary data movement operator. Swapping serves a role similar to assignment in other languages, and has been argued to be a better choice for data movement, particularly for the purposes of reasoning about code [7]. The statement x :=: y exchanges the values of x and y. A final key attribute of RESOLVE is that the language includes syntactic slots for mathematical code annotations, which allow for a sound and relatively complete proof system [8,9]. These annotations include loop invariants, termination metrics for loops and recursive operations, and indeed arbitrary mathematical assertions, which must themselves be proved, that may “assist” the automated reasoning process in discovering mathematical insights underlying the code. Our hope is to minimize the number of extra programmer-supplied assertions necessary to verify code, and in fact none of the code verified in the work for this paper required any extra assertions beyond standard loop invariants and progress metrics (which are always required). We generate VCs automatically in accordance with the RESOLVE program proof system defined formally in [9] and informally in [1]. As outlined in [1], this process can best be characterized as filling out a symbolic tracing table. We generate one VC for each line in the program where the next statement requires a pre-condition to be satisfied or a loop invariant/progress metric property to be upheld. We also generate a VC which states that, at end of the code being verified, the implementation has met its obligation as stated in its contract. Note the modularity of this approach: requirements on legally calling operations are proven to be met on the client’s side, whereas the correct behavior of program units assuming satisfied pre-conditions is verified once-and-for-all in isolation. The VC generator works in two phases. The by-rote VC generation of phase one introduces a large number of mathematical variables: one for each program variable in each program state (roughly speaking, we consider the execution of each line of code in the program to define a new “program state” or “program point”). For instance, xi stands for the value of program variable x in state i. In a program with n variables and m statements, the VCs contain a total of nm distinct mathematical variables at the end of phase one, and of course each variable may actually occur multiple times. The simplification phase of the VC generator then applies a few theoryindependent logical restructuring rules to each VC. The most obvious and useful simplification is basic substitution. A majority of the nm-many variables are removed by this step. For instance, the hypotheses in the original VCs often contain clauses which indicate that the value of some variable was preserved from one program state to the next, e.g., x10 = x9 . Upon encountering this situation we replace x10 by x9 throughout the VC and remove this clause altogether.
34
J. Kirschenbaum et al.
Any effective back-end automated prover would certainly be able to apply such substitutions to achieve the same effect, but the VC generator does this before handing the VCs to an automated prover so the human-readable output of the VC generator is more concise. The second phase also makes various structural changes to VCs in an effort to render them more tractable for processing by an automated theorem prover. An example is the explicit introduction of case analysis. In our experience, useful case analysis can rarely be performed spontaneously by a back-end automated prover. Requiring human advice about appropriate cases seems to be the norm, and certainly is necessary in general. However, the kinds of case splits required for discharging VCs, rather than arbitrary mathematical sentences, are relatively simple and can usually be deduced from the structure of the code. The VC generator therefore makes case splits explicit. The simplification phase divides each VC into appropriate cases based on the control flow of the code, thus obviating the need for any special insight or assistance on the prover’s behalf. The net result of the two-phase VC generation process is that, while there are normally many VCs even for a relatively short piece of code, based on anecdotal experience, each VC tends to be relatively small and “prover-friendly.” To aid our explanation of the VC classification in Section 3, we present an example software component contract along with a component extension, and code that purports to implement that extension. The software component is a stack and the extension defines an additional operation that reverses a stack. The contract is given in Fig. 1(b), and describes the behavior of the stack in terms of a mathematical model, namely a mathematical string. Each operation contract, for example Push, describes the effects of the operation on the model via requires and ensures clauses (the pre- and post-conditions of the operation, respectively). The symbol # in the ensures clause denotes the incoming value of a parameter. The contract for the Reverse operation is depicted in Fig. 1(c). This contract uses a mathematical function reverse in the ensures clause; its meaning should be unsurprising. Finally, realization code that is purported to implement the Reverse operation is given in Fig. 1(a). Note the use of the swap operator :=: in this code. Also, this code illustrates the requisite code annotation in the form of a loop invariant (the maintains clause), and a loop progress metric (the decreases clause).
3
Classification of VC Proof Techniques
We use the implementation of a stack reverse extension shown in Fig. 1(a) to illustrate the VC classification process. Figures 3 through 6 show example VCs generated by the method discussed in Section 2. Note that a VC always takes the form of a logical implication whose antecedent is a conjunction of zero or more clauses. We refer to clauses of the antecedent as “hypotheses” and the consequent as the “goal”. We represent our VCs by showing all of the antecedent’s clauses conjoined above the solid line, with the consequent written below the line.
Verifying Component-Based Software
contract StackTemplate (type Item)
realization Iterative implements Reverse for StackTemplate procedure Reverse (updates s: Stack) variable tmp: Stack loop maintains reverse (s) * tmp = reverse (#s) * #tmp decreases |s| while not IsEmpty (s) do variable x: Item Pop (s, x) Push (tmp, x) end loop s :=: tmp end Reverse end Iterative (a) Stack Reverse Implementation
contract Reverse enhances StackTemplate procedure Reverse (updates s: Stack) ensures s = reverse (#s) end Reverse
35
math subtype STACK_MODEL is string of Item type Stack is modeled by STACK_MODEL exemplar s initialization ensures s = empty_string procedure Push (updates s: Stack, clears x: Item) ensures s = <#x> * #s procedure Pop (updates s: Stack, replaces x: Item) requires s /= empty_string ensures #s = <x> * s function IsEmpty (restores s: Stack) : control ensures IsEmpty = (s = empty_string) end StackTemplate
(c) Stack Reverse Contract
(b) Stack Contract Fig. 1. Stack Example
Our classification of the difficulty of the proof requirements of VCs is presented in Fig. 2(a). Note that the categories (i.e., sets of VCs) in Fig. 2(a) have a natural structure. The L category is a subset of every other category. Each LHi is a subset of LHi+1 , each MHi is also a subset of MHi+1 , and each DHi is a subset of each DHi+1 . Finally, each LHi is a subset of MHi ; also, each MHi is a subset of DHi . This structure forms a lattice shown in Fig. 2(b). Our methodology for analyzing the RESOLVE component catalog is to instrument an in-house VC prover, SplitDecision, to analyze each proven VC to
36
J. Kirschenbaum et al.
Label What is needed in the proof L Rules of mathematical logic Hn At most n hypotheses from the VC needed (n > 0) M Knowledge of mathematical theories used in the specifications D Knowledge of programmer-supplied definitions based on mathematical theories above (a) VC Classification
DH2 MH2 LH2
DH1 MH1 LH1
D M L
(b) Lattice of the VC categorization
Fig. 2. Table of VC Categorization and Diagram of Category Relationships
determine the “lowest” category the VC is in. We do this by checking if the goal is a tautology, checking to see how many hypotheses are needed in the proof, etc. The automatic nature of this can only guarantee we find an upper bound for any VC. For example, a particular VC categorized as MH1 might in fact be M or LH1 , but certainly not MH2 or DH1 . For VCs that are true but are not proven automatically (12.5% of VCs in the study), we manually examine those VCs to determine the category. Figure 3 shows a VC that falls ⇒ reverse(s0 ) ∗ Λ = reverse(s0 ) ∗ Λ into the L category. Its proof relies Fig. 3. Example from category L only on an axiom of first order logic with equality: ∀x.x = x. We note that VCs of type L are the “most obvious” kind: no knowledge of the underlying mathematical theory nor even any of the hypotheses of the VC are needed to establish the goal. Any rigorous, technical definition of “obvious” should include all VCs of this type. s2 =Λ A VC that falls into an LHn ∧ reverse(s ) ∗ tmp = reverse(s ) 2 2 0 ∗Λ category is given in Fig. 4. More ∧ |s 2| ≥ 0 specifically, we label this VC as LH1 ∧ is initial(x 3) because it is provable by noting sim⇒ s = Λ 2 ply that the goal is one of the hypotheses. LH1 VCs clearly should be Fig. 4. Example from category LH1 considered “obvious,” whereas other LHn VCs may or may not be obvious, depending on the amount of logical deduction necessary to actually establish the implication. A VC in category M is given in |s2 | ≥ 0 Fig. 5. This VC depends only on the ⇒ s0 = Λ → |s0 | > 0 validity of the goal in the underlying mathematical theory. In this case, Fig. 5. Example from category M the goal is a direct consequence of
Verifying Component-Based Software
37
a useful theorem in the mathematical theory of strings; it can be derived using the proof rules of first order logic, plus the theory of integers to account for 0 and >. If the theorem is known and available, then this VC is surely obvious. If not, it might seem obvious to humans on semantic grounds, but a symbolic proof is several steps long. Finally, in Fig. 6 we include a ...[9 irrelevant hypotheses] VC from an implementation of the ∧ n 0 ∗ m0 = n3 ∗ m3 + p 3 well-known Egyptian multiplication ∧ m3 = m 8 + m 8 ∨ m3 = m8 + m8 + 1 algorithm to illustrate the D cat∧ IS ODD(m3 ) egory. Its proof requires three hy⇒ n0 ∗ m0 = (n3 + n3 ) ∗ m8 + p3 + n3 potheses. Without knowledge of the programmer-supplied definition of Fig. 6. Example from category DH3 IS ODD—either an expansion of the definition or the algebraic properties thereof—the VC cannot be proven. The distinction between the D and M categories is based on the current state of the components. As more MH5 4 theories are developed it is possible DH4-7 0.5% that programmer-supplied definitions 4 0.4% are moved into the mathematical theories because of their general utility. MH4 However, it is also clear that there will DH3 26 always be examples of mathematical def9 3.0% 1.0% initions that are programmer-supplied, for example the format of a particular type of input file. MH3 37 4.3%
4 Analysis of Verification Conditions The VCs analyzed for the paper are generated from roughly fifty components that comprise a total of roughly two thousand lines of source code. The code ranges from simple implementations of arithmetic using unbounded integers, to sorting arbitrary items with arbitrary orderings, and includes classical code such as binary search using bounded integers. Figure 7 shows classification data for all VCs generated from a sample catalog of RESOLVE component client code that relies on existing, formally-specified components to implement extensions,
LH2 2 0.2%
DH2 5 0.6% MH2 84 9.7%
LH1 78 9.0%
MH1 222 25.7%
DH1 2 0.2%
D 2 0.2%
M L 183 21.2%
207 23.9%
Fig. 7. VCs as categorized
38
J. Kirschenbaum et al.
which add additional functionality (e.g., the aforementioned Stack Reverse). Here, the area of each bubble in the lattice is proportional to the fraction of the 865 VCs that fall into that category. The number and percentage of all VCs falling into each category is shown in or near its bubble. Several interesting features are exhibited in Fig. 7. First, over 30% of the VCs can be proved without the use of any mathematics or more than one hypothesis. Moreover, over 75% of the VCs can be proved using no more than general mathematical knowledge along with at most one hypothesis. However, programmer-supplied definitions do tend to result in more sophisticated proofs; more hypotheses tend to be needed than in the general case. It is rare for a VC to require only a programmer-supplied definition. The programmersupplied definitions tend to encapsulate complexity; this complexity is apparent from the larger number of hypotheses needed to prove such VCs. While the number of hypotheses needed to prove VCs is interesting, the metric may mask some other properties of the VCs. For example, a VC whose proof requires a larger percentage of the hypotheses might be considered “less obvious” than a VC whose proof requires a small fraction of the hypotheses. Based on the results, this is fairly rare; the majority of VCs (over 90%) can be proved using only 30% of the hypotheses.
5
Related Work
We are unaware of any prior work that empirically examines the structure or proof difficulty of VCs. Work in this area has focused instead on the initial subproblems of generating VCs and creating tools to prove them. For example, the problem of generating VCs has been tackled using the Why methodology [10], which involves a simplified programming language, annotated with logical definitions, axioms, pre-conditions, post-conditions and loop invariants, from which VCs can be generated. A subset of both C (with annotations) and Java (with JML specifications) can be translated into the simplified programming language, such that the VCs generated are claimed to represent the correctness of the original C or Java code. The translation process from C or Java must explicitly capture the memory model of the original source language (C or Java). As a result of using RESOLVE, we do not need an explicit memory model, dramatically simplifying the generated VCs. Also addressing the problem of generating VCs, the tool Boogie [11] takes as input annotated compiled Spec# [12] code and generates VCs in the BoogiePL language. This language has support for mathematical assumptions, assertions, axioms and function definitions along with a restricted set of programming language constructs. The BoogiePL representation is used by Boogie to generate first order mathematical assertions. The method [13] used for generating VCs is similar to the method presented in Section 2. Addressing both the problem of generating VCs from program source and of creating tools that can prove the generated VCs automatically, Zee et al. [14] have used a hybrid approach of applying both specialized decision procedures
Verifying Component-Based Software
39
and a general proof assistant to prove that code purporting to implement certain data structure specifications is correct. However, the use of Java as a starting language requires that the specifications use reference equality for comparison. Our approach proves properties that depend on the values of the objects instead. To repeat, none of the above papers nor any others we know about present empirical data about the sources of proof difficulty across even a small selection of VCs, let alone hundreds as reported here.
6
Conclusion and Future Work
This paper has presented the first, to our knowledge, examination of the structure of VCs generated for client code built on reusable software components. The statistics support our hypothesis that VC proofs are mostly simple bookkeeping. Only a few VCs are structurally complicated. Moreover, the vast majority of VCs can be proved using at most three hypotheses. We have done some work using formal proof rules underlying a goal-directed approach, discussed in [8]. Preliminary results suggest that the goal-directed proof system generates fewer VCs that are comparably simple, according to taxonomy and the metrics, as the tabular method of VC generation. Further investigation of this phenomenon is in order. Our goal is to extend this work toward a more rigorous definition of obvious with a finer grained evaluation of the current VCs that is more directly connected to a particular type of prover. Performing a more rigorous comparison of different VC generation strategies along with a comparison of VCs generated using different programming languages should provide valuable additional information about the sources of difficulty of VC proofs.
Acknowledgments The authors are grateful for the constructive feedback from Paolo Bucci, Harvey M. Friedman, Wayne Heym, Bill Ogden, Sean Wedig, Tim Sprague and Aditi Tagore. This work was supported in part by the National Science Foundation under grants DMS-0701187, DMS-0701260, CCF-0811737, and CCF-0811748.
References 1. Sitaraman, M., Atkinson, S., Kulczycki, G., Weide, B.W., Long, T.J., Bucci, P., Heym, W.D., Pike, S.M., Hollingsworth, J.E.: Reasoning about softwarecomponent behavior. In: Frakes, W.B. (ed.) ICSR 2000. LNCS, vol. 1844, pp. 266–283. Springer, Heidelberg (2000) 2. Hoare, C.A.R.: The verifying compiler: A grand challenge for computing research. J. ACM 50(1), 63–69 (2003) 3. Woodcock, J., Banach, R.: The verification grand challenge. Journal of Universal Computer Science 13(5), 661–668 (2007), http://www.jucs.org/jucs_13_5/the_verification_grand_challenge
40
J. Kirschenbaum et al.
4. Enderton, H.: A Mathematical Introduction to Logic. Harcourt/Academic Press (2001) 5. Weide, B.W., Sitaraman, M., Harton, H.K., Adcock, B., Bucci, P., Bronish, D., Heym, W.D., Kirschenbaum, J., Frazier, D.: Incremental benchmarks for software verification tools and techniques. In: Shankar, N., Woodcock, J. (eds.) VSTTE 2008. LNCS, vol. 5295, pp. 84–98. Springer, Heidelberg (2008) 6. Ogden, W.F., Sitaraman, M., Weide, B.W., Zweben, S.H.: Part I: the RESOLVE framework and discipline: a research synopsis. SIGSOFT Softw. Eng. Notes 19(4), 23–28 (1994) 7. Harms, D., Weide, B.: Copying and swapping: Influences on the design of reusable software components. IEEE Transactions on Software Engineering 17(5), 424–435 (1991) 8. Krone, J.: The Role of Verification in Software Reusability. PhD thesis, Department of Computer and Information Science, The Ohio State University, Columbus, OH (December 1988) 9. Heym, W.D.: Computer Program Verification: Improvements for Human Reasoning. PhD thesis, Department of Computer and Information Science, The Ohio State University, Columbus, OH (December 1995) 10. Filliˆ atre, J.C., March´e, C.: The Why/Krakatoa/Caduceus platform for deductive program verification. In: Damm, W., Hermanns, H. (eds.) CAV 2007. LNCS, vol. 4590, pp. 173–177. Springer, Heidelberg (2007) 11. Barnett, M., Chang, B.Y.E., DeLine, R., Jacobs, B., Leino, K.R.M.: Boogie: A modular reusable verifier for object-oriented programs. In: de Boer, F.S., Bonsangue, M.M., Graf, S., de Roever, W.-P. (eds.) FMCO 2005. LNCS, vol. 4111, pp. 364–387. Springer, Heidelberg (2006) 12. Barnett, M., Leino, K.R.M., Schulte, W.: The Spec# programming system: An overview, http://citeseer.ist.psu.edu/649115.html 13. Barnett, M., Leino, K.R.M.: Weakest-precondition of unstructured programs. In: PASTE 2005: Proceedings of the 6th ACM SIGPLAN-SIGSOFT Workshop on Program Analysis for Software Tools and Engineering, pp. 82–87. ACM, New York (2005) 14. Zee, K., Kuncak, V., Rinard, M.: Full functional verification of linked data structures. SIGPLAN Not. 43(6), 349–361 (2008)
Extending FeatuRSEB with Concepts from Systems Engineering John Favaro and Silvia Mazzini Intecs SpA via E. Giannessi, 5y – I-56121 Pisa, Italy {John.Favaro,Silvia.Mazzini}@intecs.it
Abstract. FeatuRSEB is a method for domain modeling of software system families using the industry standard notation of the Unified Modeling Language. FeatuRSEB/Sys is an extension of FeatuRSEB with constructs from the SysML profile for systems engineering, augmenting it with analysis and modeling mechanisms that are upstream from the original method, while nevertheless conserving the advantages of an industry standard notation and semantics. Keywords: Domain analysis, reuse, feature, UML, SysML, systems engineering, requirements, analysis, modeling, architecture, trade studies.
1 Introduction James Neighbors introduced the term domain analysis into the literature in 1984 in an article [1] on his pioneering Draco system. Another milestone occurred in 1990 with the introduction [2] of Feature-Oriented Domain Analysis (FODA). FODA became a catalyst for the development of subsequent methods due to a number of characteristics including a straightforward scheme for capture and classification of domain knowledge that is easily understandable by humans. These characteristics have led to the development of several FODA variants over the years [3]. The FeatuRSEB [4] variant of FODA is a feature-oriented extension of an application family development method, the Reuse Oriented Software Engineering Business (RSEB) [5], arising out of collaboration between Hewlett-Packard Research and Intecs. It has two characteristics of particular interest: • It was one of the first domain analysis methods to employ the notation of the Unified Modeling Language [6]. Since then, other feature-oriented methods using UML notation have appeared [7]. These approaches have the advantage that an industry-standard modeling notation is used instead of an ad hoc, proprietary notation, and the semantics of core modeling concepts (such as classes and relationships) are not interpreted in an ad hoc fashion. This makes it easier to focus on the value-adding characteristics of the method. • Due to its origins in the Reuse Driven Software Engineering Business, nontechnical, business-oriented factors are given more explicit emphasis with respect to purely technical factors; S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 41–50, 2009. © Springer-Verlag Berlin Heidelberg 2009
42
J. Favaro and S. Mazzini
Intecs works with clients in the aerospace, automotive, space, and telecommunications industries, where we advise them on development methodologies and provide specialized toolsets such as HRT-UML for the modeling of hard real-time systems [8]. This work has exposed us to the discipline of systems engineering, which is central to the development of large systems in those industries. Based upon this experience, we have extended FeatuRSEB with modeling concepts and constructs from the Systems Modeling Language (SysML) profile [9] of the UML in order to extend its capabilities for high-level analysis for domain modeling of large software system families, while preserving the advantages of an industry-standard notation and semantics.
2 Relating Systems Engineering to Domain Engineering Systems engineering as a recognized discipline dates back to the 1950s, and has been applied with success to large and complex systems in contexts ranging from defense and air traffic control to commercial products. Systems engineering essentially consists of three major concurrent activities (Fig. 1). Requirements elicitation and documentation activities
Analyses (feasibility studies, relationships, constraints, …)
High-level system functional design
Fig. 1. Three concurrent activities in systems engineering
• Requirements elicitation and documentation is the core activity of systems engineering. • Numerous types of analyses are carried out, related to the specific disciplines involved, and may include engineering and economic feasibility studies, documentation of relationships among components, and identification and documentation of physical constraints on system elements. In particular, they may include calculations and formulas related to non-functional requirements. • High-level system functional analysis identifies the principal subsystems, their interfaces, and dataflows through those interfaces. Although each of these activities superficially appears to have a direct counterpart in the software engineering life cycle, their nature and purpose are different in systems engineering. Requirements are first-class citizens in systems engineering (in the sense that they are elicited, documented, and managed as separate entities) because they are an output of the systems engineering process, whereas in software engineering processes, requirements tend to be managed as an input. In fact, it would be only a slight exaggeration to state that systems engineering is mostly concerned with eliciting requirements of systems and about analyzing the feasibility of designs. Requirements are elicited with the support of analyses that in turn elicit relationships and constraints among different parts of the system. The documentation of these analyses, trade-off studies, and associated decisions is likewise considered a firstclass citizen in systems engineering, rather than an afterthought as so often happens in
Extending FeatuRSEB with Concepts from Systems Engineering
43
software systems design (often something as poor as a simple text field to “describe rationale in 256 characters or less”). This elevation of rationale and decision-making documentation to first-class citizenship is in line with recent awareness in the software engineering community of its importance, e.g. through the addition of the Decision View in the standard 4+1 views model of software architectural description [10]. In domain analysis it is even more important, where the recording of trade-off and decision-related information for entire families of systems is crucial for informing the feature selection process for subsequent domain engineering of systems. The term “functional analysis” in systems engineering has a more general meaning than in software engineering. This is so in large degree because it is essential for determining subcontracting boundaries: systems engineers construct the product tree of all identified components of the system (including the software component) and then each such component is contracted out to others to construct (it is not unusual for a systems engineering organisation to have no construction capability at all). Requirements elicitation, analysis and decision-recording, and system component management mechanisms are much less well developed in software engineering processes because they are upstream from where software engineering processes generally start. Indeed, in the ECSS-E40 standard of the European Space Agency for software engineering [11], systems engineering activities are explicitly defined to be precedent to the software engineering activities. This is where the relationship of system engineering to domain engineering emerges: domain engineering is also upstream from the traditional (single-system) software engineering process. The outputs of domain engineering also serve as inputs to the activities for engineering (single) software systems. Therefore, in retrospect it is not surprising that we found precisely these mechanisms from systems engineering to add significant value to the domain modeling process.
3 Introducing SysML into Domain Analysis: The Domain Models The table in the Appendix summarizes the models and approach of FeatuRSEB/Sys, describing also the ways in which each model handles variability. In this section we discuss in more depth those models which integrate systems engineering concepts. 3.1 Context Model Context analysis was introduced in original FODA. The purpose of the context model is to define the scope of the domain that is likely to yield exploitable domain products. FeatuRSEB/Sys context diagrams are represented as SysML block diagrams. Standard UML is biased toward the concrete development of software systems: it naturally forces thinking in terms of objects and methods, quickly driving toward design. (Indeed it has been suggested by the inventors of FODA that it has been pushed beyond its original intention of analysis into design). At the highest levels of domain engineering, though, interfaces are much more important than specific “methods” on classes. With SysML blocks (thought of as “whited-out classes”) the domain analyst is freed from the “tyranny of the methods.” As in other FODA
44
J. Favaro and S. Mazzini
variants, context analysis provides the high level connections among major components related to the target domain. The exchange of information (dataflow) with external actors (peer domains) and lower domains is indicated at block boundaries by means of SysML flow ports. The SysML blocks and flow ports help to pull the context analysis up to a higher level of abstraction more suited to domain engineering. 3.2 Domain Dictionary The domain dictionary consolidates the definitions of all terms used in the domain and is updated over time. In FeatuRSEB the feature model did “double duty” as a domain dictionary, and this is also true in FORM [12] to a degree. In FeatuRSEB/Sys the domain dictionary is separate and explicit, serving the same role as in systems engineering of establishing a common basis for communication among all participants in the domain implementation activities. 3.3 Domain Requirements Model In FeatuRSEB the use case model alone represented user requirements, relieving the feature model of FODA from doing double duty to represent both user requirements and reuser features. In FeatuRSEB/Sys a similar phenomenon occurs: the use case model is relieved from representing both use scenarios and implicitly the requirements they embody, by adding a requirements model to model the requirements explicitly. Requirements reuse has received some attention in the literature [13], but its integration into domain analysis methods tends to take the form of implicit inclusion in domain use case models and to some extent feature models. We argue that a separate domain requirements model is a useful addition to the set of domain analysis models, for at least two reasons: first, although use case models are often referred to as “requirements models”, we subscribe to the point of view currently argued by many that use cases are at a lower level of abstraction than the requirements themselves – rather, use cases generally represent the results of requirements analysis; second, an explicit requirements model is particularly useful for documenting many types of technical, organizational, economic, and legal non-functional requirements, which are not handled well by use case techniques with their bias toward functional requirements, but which a domain analysis must capture in order to be complete. In short, explicit modeling of domain requirements contributes to keeping the level of abstraction of the domain analysis as high as possible. SysML provides an explicit requirements diagram (Fig. 2), which can serve as an important starting point for reusable requirements for new systems in a domain. For example, it gives the domain analyst a place to document the cost of implementing reusable requirements [14]. Furthermore, the requirements model allows requirements management tools to link from the requirements to their implementation in domain systems. This supports requirements traceability, and thereby provides support not only for the construction phase of domain engineering, but also for V&V, which has a heavier footprint in larger, more complex systems.
Extending FeatuRSEB with Concepts from Systems Engineering
45
Fig. 2. Two requirements from the domain requirements model corresponding to the telecommunications example in [4]. The requirement on the right-hand side could not be easily captured and modeled using only use case techniques.
3.4 Analysis Models In the UML, analysis has a rather narrow meaning, involving the transition from use cases to object design. FeatuRSEB inherited Jacobson robustness analysis from the RSEB for this purpose. But in systems engineering, analysis has a more general meaning, and is more about exploring feasibility, relationships and constraints at high system levels (relationships between large blocks of system functions), and in general doing supporting analysis to ensure that a system functional architecture is sound and cost-effective. In UML, there are no standard ways to document such characteristics. Some progress is being made with improved mechanisms for describing constraints, but in general the user is left to his own devices. In SysML, a new diagram has been introduced solely for documentation of constraints and relationships among system parts. Parametric diagrams are used to capture the properties of the applications or subsystems of the domain. They can express powerful constraints that abstract away specific constraints of individual systems into more general constraints (e.g. expressed in terms of formulas) characterizing aspects of system families. For example, perhaps a «performanceRequirement» can only be satisfied by a set of constraints along with an associated tolerance and/or probability distribution, or a «functionalRequirement» might be satisfied by an activity or operation of a block. Likewise, cost constraints can be explicitly documented in parametric diagrams. par [ ConstraintBlock] C
tf
tf
ts
ts
eq1: CallDuration {d = tf – ts - d}
ts
d
r
d
eq3: CostCalc
r
{C = r * d + b}
C
C
eq2: RateCalc rt
rt
{r = lookup (rt, ts)}
refines «requirement» Time-period based invoicing
Fig. 3. Parametric diagram for billing feature (simplified) in model of [4], to support analysis and identification of input parameters that must be made available by a domain architecture to support implementation of a requirement for time-period based call invoicing
46
J. Favaro and S. Mazzini
Parametric diagrams help the domain analyst to analyze constraints on the domain architecture needed to satisfy particular requirements. For example, in [4] one feature variant for the telephone call invoicing subsystem had a requirement to be able to support invoicing based upon time periods (e.g. “late night,” “daytime,” etc.). A parametric diagram (Fig. 3) helps document an analysis to identify the input parameters for such a feature that an architecture will have to support. Such an analysis supports refinement of the requirement and feasibility and cost studies. Feature modeling permits the documentation of reusable functionality – but what about reusable “non-functionality”? Domain analysis methods have not traditionally provided strong support for a reuse-oriented documentation of non-functional aspects of system families. For example, the theory and methods used to analyze performance constraints in families of real-time systems form an important part of their construction and documentation. The constraint blocks of SysML make it possible to package and document non-functional aspects as reusable artifacts (Fig. 4). Using the SysML concept of allocation, variability can be modeled with such mechanisms – for example, two different algorithms could be allocated to different system variants. bdd [ Package] Analysis Models
«constraint» Earliest Deadline First Model constraints
⎧ ⎨/U = ⎩
n
∑ i −1
⎫ Ci ≤ 1⎬ Ti ⎭
«constraint» Rate Monotonic Model constraints
(
)
n ⎧ ⎫ Ci n ⎨/ U = ∑ ≤ n 2 − 1 ⎬ T i − 1 i ⎩ ⎭
{size(T) = n & size(C) = n}
parameters T: Real [*] {ordered, unique} /U: Real C: Real [*] {ordered} n: Integer
parameters T: Real [*] {ordered, unique} /U: Real C: Real [*] {ordered} n: Integer
Fig. 4. Reusable analysis models for hard-real time system families packaged as constraint blocks
It is important to emphasize that, especially in a context of domain engineering of large and complex systems in the sectors in which our clients operate, those decisions which concern the scope of system families and the number of variations supported in a domain architecture are primarily business driven: considerations: the effort, time and costs required for domain design and implementation must be less than the effort, time and costs that would be required for the expected number of domain applications that may reuse the domain engineering results. Here FeatuRSEB/Sys inherits the business decision mechanisms from the Reuse Oriented Software Engineering Business upon which original FeatuRSEB was based. The difference is that the means to document these decisions is now provided in the new mechanisms from SysML. In particular, the parametric diagram mechanism supports the domain analyst in what in systems engineering are called trade (or trade-off) studies, whereby so-called measures of effectiveness (“moes”) are defined within an analysis context (Fig. 5).
Extending FeatuRSEB with Concepts from Systems Engineering
47
PhoneLine values «moe» throughput: T «moe» reliability: R «moe» quality: Q «moe» services: S
VOIP
POTS
values
values
«moe» throughput: T = 0.83 «moe» reliability: R = 0.75 «moe» quality: Q = 0.65 «moe» services: S = 0.95
«moe» throughput: T = 0.65 «moe» reliability: R = 94 «moe» quality: Q = 0.67 «moe» services: S = 0.45
Fig. 5. SysML analysis context for trade analysis for the phone line quality feature variants in [4] according to selected measures of effectiveness («moe»). Here another mechanism for handling variability is illustrated: the PhoneLine abstraction captures the variability between VOIP and POTS alternatives. Different objective functions will place emphasis on different characteristics (e.g. superior service offering flexibility on VOIP line or higher reliability of POTS line), allowing the domain engineer to select feature variants based upon the needs of the particular system.
3.5 High Level Generic Architecture SysML block diagrams are used to describe the top level partitioning of the domain system capabilities into functional blocks, as refinements of the context model structure diagrams; these blocks are defined as black boxes by putting the emphasis on provided and required interfaces. These interfaces do not require a full signature, but mainly describe named entities as SysML dataflows. Dataflow entities exchanged between domains and data that are handled by toplevel components (blocks) in the domain are described, categorized (by inheritance) and clustered (by aggregation) using object oriented technology, in order to provide their data structure. For this purpose UML class diagrams are used in a separate data package, thus describing the data model for information exchanged in the domain. The package may correspond to a library of data types available at domain level. The functional model identifies the functional commonalities and differences of the applications in the domain. The elements of the specification of a functional model can be classified in two major categories: First, specification of functions describes the structural aspects of the top level partitioning of the applications in terms of inputs, outputs, internal data, logical structures and data flow among them. Second, specification of the functional and dynamic behavior describes how an application behaves in terms of events, inputs, states, conditions and state transitions, sometimes defined as control flow. Activity diagrams and UML StateCharts are generally used to describe functional models, but other discipline-specific methods and languages may also be used, such as those used to model mechanical or control aspects of systems.
48
J. Favaro and S. Mazzini
3.6 Feature Model The feature model in FeatuRSEB/Sys remains the “+1” model as described in original FeatuRSEB, summarizing the results of domain analysis and tracing the features back into the respective domain models, whereby the traces are extended to the other, additional models that have been introduced (e.g. the requirements model). In original FeatuRSEB a notation for the feature model was devised by extending the UML with stereotypes for describing the features and their relationships. This notation remains valid for FeatuRSEB/Sys, retaining the advantage of using the UML.
4 Conclusions and Further Work Systems engineering places emphasis on activities that are upstream from those of software engineering, whereby outputs considered valuable include requirements, feasibility analyses and trade studies, and high level functional breakdown at a higher level of abstraction than in software system architecture. The same is true of domain engineering, and the new concepts and diagrams of SysML help to raise the level of abstraction in domain analysis back to where it was originally conceived. It also provides another advantage: the feature model in the feature-oriented approaches is in its essence a mechanism for organization and traceability. Systems engineering provides extended mechanisms for traceability – of requirements, of analyses, and the like – that make it possible to broaden the scope of traceability and provide a more complete documentation of the domain analysis. FeatuRSEB/Sys originated in the COrDeT project of the European Space Agency, where it was used in the modeling of onboard Space system families [15]. Related efforts in modeling techniques are underway in other contexts – for example, the EAST-ADL2 profile for an automotive architectural modeling language that incorporates concepts and mechanisms from SysML [16]. Tool support is an important aspect of feature-oriented domain modeling, and significant progress has been made since its introduction [17]. The choice of UML and SysML is important not only for notational uniformity and familiarity, but for its implications for tool support. The combination of the improved UML Meta Object Facility (MOF) and its support by the Eclipse framework has made model based development of specialized tools feasible with reasonable costs. The provision of complete tool support for FeatuRSEB/Sys will be the focus of future efforts.
References 1. Neighbors, J.: The Draco Approach to Constructing Software from Reusable Components. IEEE Trans. Software Eng. 10(5), 564–574 (1984) 2. Kang, K., Cohen, S., Hess, J., Nowak, W., Peterson, S.: Feature-Oriented Domain Analysis (FODA) Feasibility Study. Technical Report CMU/SEI-90-TR-21. Software Engineering Institute, Carnegie Mellon University, Pittsburgh (1990) 3. Frakes, W., Kang, K.: Software Reuse Research: Status and Future Directions. IEEE Transactions on Software Engineering 31(7) (July 2005)
Extending FeatuRSEB with Concepts from Systems Engineering
49
4. Griss, M., Favaro, J., D’Alessandro, M.: Integrating Feature Modeling with the RSEB. In: Fifth International Conference on Software Reusability, pp. 76–85. IEEE Press, New York (1998) 5. Jacobson, M., Griss, M., Jonsson, P.: Software Reuse: Architecture, Process and Organization for Business Success. Addison-Wesley-Longman, Menlo Park (1997) 6. Rumbaugh, J., Jacobson, I., Booch, G.: The Unified Modeling Language Reference Manual, 2nd edn. Addison-Wesley, Boston (2004) 7. Gomaa, H.: Designing Software Product Lines with UML: From Use Cases to Patternbased Software Architectures. Addison-Wesley, Boston (2004) 8. Mazzini, S., D’Alessandro, M., Di Natale, M., Domenici, A., Lipari, G., Vardanega, T.: HRT-UML: taking HRT-HOOD into UML. In: Proc. 8th Conference on Reliable Software Technologies Ada Europe (2003) 9. The Object Management Group, Systems Modeling Language (OMG SysML), Final Adopted Specification, document ptc/06-05-04 (2006), http://www.omg.org 10. Kruchten, P., Capilla, R., Dueñas, J.C.: The Decision View’s Role in Software Architecture Practice. IEEE Software 26(2), 36–42 (2009) 11. European Space Agency, ECSS-ST-40C – Software General Requirements (March 6, 2009), http://www.ecss.nl 12. Kang, K., Kim, S., Lee, J., Kim, K., Shin, E., Huh, M.: FORM: a feature-oriented reuse method with domain-specific reference architectures. Annals of Software Engineering 5(1), 143–168 (1998) 13. Lam, W.: A case-study of requirements reuse through product families. In: Annals of Software Engineering, vol. 5, pp. 253–277. Baltzer Science Publishers, Bussum (1998) 14. Favaro, J.: Managing Requirements for Business Value. IEEE Software 19(2), 15–17 (2002) 15. Mazzini, S., Favaro, J., Rodriguez, A., Alaña, E., Pasetti, A., Rohlik, O.: A Methodology for Space Domain Engineering. In: Proceedings Data Systems in Aerospace (DASIA), Palma de Majorca, Spain (2008) 16. Lönn, H., Freund, U.: Automotive Architecture Description Languages. In: Navet, N., Simonot-Lion, F. (eds.) Automotive Embedded Systems Handbook. CRC Press, Boca Raton (2009) 17. Antkiewicz, M., Czarnecki, K.: FeaturePlugin: Feature Modeling Plug-in for Eclipse. In: Eclipse 2004: Proceedings of the 2004 OOPSLA Workshop on Eclipse Technology eXchange, OOPSLA, pp. 67–72. ACM Press, New York (2004)
50
J. Favaro and S. Mazzini
Appendix: Summary of FeatuRSEB/Sys Models and Method Domain model Sub-components and components Notation(s) Context model
Context diagrams – SysML block diagrams
Use case diagrams – SysML use case diagrams
Utilization Positioning of the target domain with respect to higher, peer and lower domains. Variability expressed through different diagrams Description of domain capabilities. Variability expressed through different diagrams Updated throughout the domain analysis
Domain dictionary Requirement model
Text
High level generic architecture
Top-level partitioning (into Refinement of the context model applications) – SysML Block structure diagrams diagrams
Requirement diagrams – SysML Requirement diagrams
Link to Use cases and Blocks. Required variability has to be explicitly specified by link to related use cases and/or blocks and by link or requirement annotation.
Data package (library of data Data flow entities exchanged between types/structures) - UML domains and data handled by top level class diagrams components are described, categorized (by inheritance) and clustered (by aggregation) Application capabilities Application Use cases – SysML Use case diagrams Application Behaviors – SysML Interaction (sequence) diagrams Functional model
Feature model
Refinement of context level Use cases
Structural aspects of top level partitioning (inputs, outputs, internal data, logical Specification of functions – structures and data flow among SysML activity diagrams applications). Specific of dynamic behavior Application behavior (events, inputs, – SysML StateChart states, conditions and state transitions) Parametric diagram – SysML Capture functional and non functional Parametric diagram requirements through formulation of constraints. Document trade-off studies on architectural variants, including cost and performance factors. Feature model – UML Synthesis of domain analysis variability notation from FeatuRSEB as emerging from the above models.
Features Need Stories Sidney C. Bailin Knowledge Evolution, Inc., 1221 Connecticut Ave. NW, STE 3B, Washington DC 20036 [email protected]
Abstract. We present an extension of the notion of feature models. An ontology of stories clarifies the meaning of potentially ambiguous features in situations where there is no unified domain model, and where candidates for reuse have varied provenance. Keywords: features, domain model, story, ontology, evaluation.
1 Introduction This paper argues that feature models, while an essential tool for reuse in any domain, are not in themselves sufficient for the capture and communication of knowledge about variability. We argue that features carry a relatively small amount of semantics, if any at all, and that much of the intended semantics remain implicit in naming conventions, or tacit in experience, or undocumented in hearsay. We suggest that the missing semantics, addressing fine-grained questions of context, interface, function, performance, and rationale, can be usefully conveyed through stories attached to features. By story we mean something relatively specific, not simply a chunk of text. There are several attributes that make something a story, but one of the key attributes is that of being situated. In a story, context is (almost) everything. Examples of the kinds of stories we are looking for already exist in the user feedback sections of many web-based product catalogues. User feedback contributions, despite their unstructured form, tend to be highly situated and, thus, are often good examples of the notion of story we are advocating. Consumer assistance product reviews, on the other hand, are often much less situated; for this reason, they often fall short both in their sense of urgency and in the amount of crucial background information they provide. We are not simply advocating for stories. That is an argument we have made elsewhere [1]. Nor are we arguing here for a particular kind of feature model: that, too, we have addressed elsewhere [2]. In this paper we are specifically interested in the way in which stories can be used systematically to enrich the semantics of a feature model. At the core of this vision lies interplay between the formal and the informal. The bulk of the paper consists of a case study that involved the evaluation of alternative technologies for a particular function within a complex system of systems. We argue in Section 1.1 that the evaluation of alternative candidates is the essence of S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 51–64, 2009. © Springer-Verlag Berlin Heidelberg 2009
52
S.C. Bailin
the reuse process. Our goal is not, however, to present a methodology for trade studies, but rather to explore the kind of contextual information that is necessary in order to perform such evaluations, and to draw conclusions from this about the structure and contents of domain models. Our conclusions are applicable to virtually any domain modeling method. 1.1 Features and Engineering Analysis Many opportunities for reuse occur in situations lacking a well-developed domain model, and in which the resources required for a full-scale domain analysis (not just money but also time) are unavailable. Such opportunities cannot take advantage of feature-based reuse methods [3] and product-line architectures [4]. Yet they are far more systematic than what is often termed opportunistic reuse. We will call this real-world reuse. These situations are often opportunities for knowledge reuse: the primary decision is to choose an existing, well-defined technical approach to solve a problem. The technical approach is typically selected through an engineering analysis involving goals, priorities, and tradeoffs. Thus, knowledge reuse is closely related to the disciplines of engineering analysis. Such situations, however, often invite reuse not just of knowledge but of actual software, for the simple reason that the technical approaches are realized in software. Thus, there is a deep connection between software reuse and the process of engineering analysis—evaluating alternative technologies to meet a set of requirements. Conversely, any software reuse decision ought to involve an evaluation of alternatives. At a minimum, the question of make vs. buy (develop vs. reuse) should be addressed. Beyond that, if there are multiple candidates for reuse, or multiple features that may or may not be selected, then a systematic evaluation of tradeoffs ought to occur. But real-world reuse, lying somewhere between systematic and opportunistic, illustrates a limitation of feature models. Because it occurs without a unified domain model, the features considered in the tradeoff studies are not necessarily comparable from product to product, let alone from study to study. There is no controlled vocabulary with which to describe and evaluate the alternative solutions. 1.2 Features and Ontologies In a previous paper we described the use of ontologies to represent KAPTUR-style domain models: problems, alternatives solutions, their features, rationales, and tradeoffs [5]. We noted that ontology mismatches arise when there are many parochial models of a domain rather than one unified model, and we described a process of progressive resolution of mismatches. In the LIBRA method, this process of resolving models-in-conflict is viewed as the very essence of reuse [6]. Aspects of the parochial contexts can be formalized to provide enriched semantics for their respective feature sets. Using ontologies, which are intrinsically open-ended, we can add concepts for disambiguating features that have slightly different meanings in different contexts (see Section 4.1). But there is a point of diminishing returns at
Features Need Stories
53
which formalization may not be appropriate, at least not until the domain reaches a certain level of maturity. The appropriate medium for capturing this context is, in such cases, narrative. 1.3 What Is a Story? By story we mean a communication that speaks of characters responding to some situation. The characters need not be people; they can be organizations, systems, computers, software programs or even designs. Something about the initial situation is unstable and causes the characters to act. The actions change the situation, and what follows is a succession of situations requiring action, and actions taken in response. This is the forward movement of the story. The emphasis is on causation, or, from another point of view, rationale. Stories are an especially effective mode of communication because they draw the reader into the story world. This only happens, of course, if what is at stake for the characters is also a concern for the reader. When this happens, the immersive nature of the story and its forward movement give the communication an urgency and sense of reality that ordinary communications lack.
2 Case Study We illustrate our arguments with a real case study that involved selecting software for use in a large, complex system of systems (SoS). The primary tradeoff was a make vs. buy decision; but, as we shall see, each of the alternatives involves some form of reuse. Salient features of the SoS, which will remain anonymous in this paper, include life-critical functions, high cost, and a complex network of stakeholders including multiple engineering and development organizations. The application we consider here is a relatively small part of the SoS, responsible for transmitting large volumes of structured data between two major SoS components. The data stream contains sequences of fields in many different data types and occurring with different frequencies. Different fields originate from different sources, and are routed to other component systems belonging to different stakeholders. This is illustrated in Figure 1.
System A
System B
Fig. 1. A data transmission application serves as a case study
54
S.C. Bailin
We called this a compression trade study because the primary challenge is to transmit the data efficiently by compressing it into a compact form, then decompressing it upon receipt. 2.1 Evaluation Criteria Table 1 shows the criteria used to evaluate the alternative compression technologies. Table 1. Evaluation criteria used in the case study
Criterion Encoding / decoding speed
Encoding / decoding software cost Transmission speed
Interoperability
Learning curve / programming complexity
Maturity
Tool availability Tool reliability
Evolvability
Risk
Description Speed at which messages can be encoded into their compressed format and then decoded by the receiving end Cost of acquiring and maintaining the software that performs the encoding and decoding Direct measure of the size of the compressed messages, which must be averaged over the likely variations in message types and content Availability of the proposed encoding method on different systems, and the expected level of confidence that the implementations on different systems are compatible Complexity of an encoding method has a direct impact on the cost of any project-developed software implementing the method, but it may also limit the range of available COTS implementations, and lessen confidence that the implementations are correct Assessed both temporally (how long the method has been in existence) and spatially (how widely it has been used) Availability of software to perform the selected functions The level of confidence that the tool will perform its functions continuously and correctly, where continuity includes the traditional systems engineering notion of availability, while correctness refers to the satisfaction of functional and performance requirements (throughput/response time) Includes the ability of the selected technology to handle evolution in the data stream contents, and the potential impact of evolution in the compression method itself (as in the evolution of standards) General unknowns
Features Need Stories
55
The evaluation criteria are not mutually independent, but each has a unique emphasis that warrants its being considered explicitly. 2.2 Alternatives Considered Table 2 identifies the alternative methods that were evaluated: Table 2. Alternative solutions considered in the case study
Solution Custom packing maps
Description The format of the data stream messages is defined explicitly in terms of the admissible fields, their sequencing, and their respective length Abstract Syntax Notation ASN.1 is an international standard for describing (ASN.1) Packed Encoding structured data [7]; the PER is part of the standard that Rules (PER) provides for a compact binary encoding of such data Fast Infoset [8] An international standard for binary encoding of data represented in the Extensible Markup Language (XML) Lempel-Ziv (LZ) A family of compression technique used by tools such compression [9] as WinZip and Gzip Efficient XML Interchange An emerging recommendation of the World-Wide (EXI) Web Consortium (W3C) for binary encoding of XML data [10] These alternatives represent the gamut from the conventional approach for such systems as previously developed (custom packing maps), through international standards (ASN.1 and Fast Infoset) and widely used file compression techniques (LZ), to a recent W3C recommendation for binary XML transfers (EXI). The alternatives vary significantly in their levels of maturity, but there is a logic to their consideration. The custom packing map approach is the organization’s legacy approach for this type of system. ASN.1 and XML are the two primary standards for expressing structured data outside of programming and formal specification languages. There are several standard encodings for ASN.1, but PER is the primary encoding for efficient binary data transfer. Similarly, Fast Infoset is a current standard for binary encoding of XML, while EXI is an emerging standard for the same purpose, whose definition has itself taken into account many of the alternatives. Finally, LZ compression is widely used in a variety of tools familiar to the engineers responsible for designing and implementing the system. Further complicating the study is the role of another international standard that would govern the way in which a custom packing map would be specified. To some extent this mitigates the “custom” nature of this alternative (as does the fact that it, alone among the alternatives, draws heavily from the organization’s past experience).
56
S.C. Bailin
3 Reuse in the Case Study The case study does not sound like a typical reuse scenario. There is no repository of reusable components, and no domain model from which systems can be instantiated through a selection of appropriate features. Nevertheless, the case study illustrates what we are calling real world reuse. It is an example of reuse because each of the alternative solutions is a form of reuse. This is clear in the case of the off-the-shelf candidates; perhaps less obvious, but equally true, is reuse in the case of the custom packing map, which is the approach the organization had used in all previous systems. At the very least, if a custom packing map were to be adopted, fundamental design concepts from prior systems would be reused; more likely, there would be adaptation of existing source code as well. Why, then, does the case study appear to be more like a conventional engineering design analysis than a case of reuse? One reason is that the evaluation was performed not at the level of functionally equivalent alternatives (for example, alternative implementations of the ASN.1 PER), but rather at the level of alternative functional approaches. Formally, however, this is no different from conventional reuse: we have a specification at a certain level of abstraction, and the candidates for reuse are alternative realizations of the specification. In this case, we lack a unified feature model for characterizing the alternative solutions. But the evaluation criteria serve, in effect, as features. Conversely, in a feature-based reuse process, the features may be considered evaluation criteria in the selection of a solution. Viewed in this way, every tradeoff analysis creates a kind of domain model, but each model is usually unique to the analysis; they are not easily compared, which makes it difficult to base decisions on prior analyses that were performed in different contexts. 3.1 Features with Values One objection to viewing evaluation criteria as features is that the criteria are attributes with values, while features are often viewed as things to be selected, i.e., the candidate either has the feature or it does not. This effectively restricts features to attributes with values in a finite enumeration set (such as Boolean-valued attributes). It is an arbitrary limitation that dispenses with information essential to specifying or evaluating reusability. For example, an efficiency feature could take values in an enumeration set consisting of the time-complexity classes such as Logarithmic, Linear, Polynomial, etc. But it might equally well take the form of more detailed testing results that graph specific response times against different inputs. The studies we consulted follow the latter approach—rightly so, because they tested different classes and distributions of input. The efficiency feature carries implicit semantics that must be made explicit for proper comprehension.
4 Integrating Multiple Feature Models Having identified the alternative solutions and the criteria for evaluating them, we studied the literature to see what was already known. There was a substantial body of
Features Need Stories
57
prior work on just this problem, but none of the studies we found used exactly the same set of candidate solutions and none used exactly the same evaluation criteria. The studies varied in their scope, in the level of rigor, and in the detailed definition of features (especially performance features). Not surprisingly, the studies also differed from each other in their conclusions. As an example, Table 3 lists the criteria from a study by Qing&Adams along with their respective priorities [11]. Table 3. Evaluation criteria considered by Qing&Adams
Criterion High Compression Ratio Low Processing Overhead No Semantic Ambiguity 3rd Party API Support
Priority Required Required Required Desirable
These criteria resemble ours but are somewhat different. High compression rate is effectively synonymous with our transmission speed criterion, while low processing overhead corresponds to our encode/decode speed. We implicitly required that all the candidates be semantically unambiguous, but we did not specify this explicitly. Finally, their 3rd party API support could facilitate our interoperability, and could improve our tool availability; but their criterion is more specific and does not necessarily imply ours. Table 4. Candidate solutions considered by Qing&Adams
Solution Gzip and Bzip wbXML ASN.1 wbXML + Zip ASN.1 + Zip XML Binary Optimized Packaging (XOP): Message Transmission Optimization Mechanism (MTOM) XMill
Description Bzip is an alternative compression algorithm using Burrows-Wheeler methods [12] WAP Binary XML, developed by the Open Mobile Alliance [13] Apparently the PER encoding although this is not clear wbXML encoding followed by Gzip or Bzip compression ASN.1 encoding followed by Gzip or Bzip W3C recommendation dating from 2005 [14] W3C recommendation for binary message transmission especially in the context of the Simple Object Access Protocol (SOAP) [15] Open source XML compressor that claims better performance than (for example) Gzip [16]
58
S.C. Bailin
The alternative solutions considered by Qing&Adams are also similar but not identical to our set, as shown in Table 4. Of the four evaluation criteria in Table 3, the latter two (no semantic ambiguity and 3rd part API support) were quickly disposed of as being satisfied by all candidates, leaving compression ratio and processing overhead as the focus of the study. Most of the other studies focused on these two criteria, as well. The meaning of the terms, however, varied from study to study. Now we look at some of the criteria used by the EXI committee. Table 5 shows 7 out of the 21 criteria they applied: those that correspond or are closely related to our criteria [17]. Table 5. Subset of evaluation criteria used by the W3C EXI committee
Criterion Compactness Forward compatibility Implementation cost
Platform neutrality Processing efficiency
Transport independence
Widespread adoption
Description Amount of compression a particular format achieves when encoding data model items. Supports the evolution of data models and allows corresponding implementation of layered standards. How much time does it take for a solitary programmer to implement sufficiently robust processing of the format (the so-called Desperate Perl Hacker measure). Not significantly more optimal for processing on some computing platforms or architectures than on others Speed at which a new format can be generated and/or consumed for processing. It covers serialization, parsing and data binding. Only assumptions of transport service are "error-free and ordered delivery of messages without any arbitrary restrictions on the message length". Has been implemented on a greater range and number of devices and used in a wider variety of applications.
Table 6 illustrates the relationships between the criteria used in our case study and those used by the EXI committee. Some of them—such as widespread adoption—are intrinsically “soft” in that they admit of varying interpretations. For these, the value of elaborating the meaning with stories may be obvious. For example, what were the experiences of projects that adopted the technology? To drive our argument home, however, we focus on one particular feature that should, on the face of it, be relatively well-defined: compactness. 4.1 Semantics of the Compactness Feature The term compactness is ambiguous because it must cover a wide range of inputs. If we had only one input instance, compactness could be reduced to a positive
Features Need Stories
59
Table 6. Relationships between our evaluation criteria and those of the EXI study
Our Criterion Encoding / decoding speed Encoding / decoding software cost Transmission speed Interoperability Learning curve / programming complexity Maturity Tool availability Tool reliability Evolvability
Relation Synonymous with Includes off-the-shelf purchase cost as alternative to Effectively synonymous with Enhanced by
EXI Criterion Processing efficiency Implementation cost
Compactness
Increases
Platform neutrality Transport independence Implementation cost
Indicated by Indicated by Weakly indicated by Partially supported by
Widespread adoption Widespread adoption Widespread adoption Forward compatibility
integer-valued attribute, namely the size of the output. In reality, though, it must represent an aggregate assessment over a set of inputs. Resolving the ambiguity requires deciding on the sample inputs to use, the classes in which to group them, and the kind of aggregation to perform, e.g., averages, distributions, peaks, or some other measure. For example, Qing&Adams used as input 9 files from the Extensible Access Control Markup Language (XACML) conformance test suite [18], ranging in size from 2KB to 1MB [11]. Mundy et al created a custom application for exchanging attribute certificates to compare XML and ASN.1 [19], while Cokus&Winkowsi created test sets to resemble the exchange of binary formatted military messages [20]. The EXI study involved a detailed definition of widely varying use cases [21], while Augeri et al created a corpus modeled on the widely used Canterbury corpus for compression evaluations [22, 23]. How do we compare, contrast, and aggregate such various tests? Viewing a feature model as part of an ontology [5], we can create placeholders in which to add the relevant information. For example, the alternative candidates can have a property test results, which are then linked to the relevant features of the candidate as well as to the test set employed, as illustrated in Figure2. This provides a unified view of the past studies. It does not, however, provide much help in comparing the different results. How should one understand the differences in test sets? The EXI tests, for example, correspond to a set of 18 use cases, including Metadata in broadcast systems, Floating point arrays in the energy industry, X3D graphics compression, serialization, and transmission, Web services for small devices, Web services within the enterprise, etc.
60
S.C. Bailin
Candidate
hasTestResults
Test Results
obtainedUsing
Test Set
hasFeature
indicates
Compactness
Fig. 2. The open-world character of an ontology allows us to add contextual information to a feature model
We could add use cases as first-class objects and associate them with the corresponding test sets. Figure 3 illustrates part of the resulting ontology.
hasRationale
supports Test Set
Justification
Use Case occursIn
describedBy involves
Domain
Stakeholder
Scenario
Fig. 3. The feature model can be enriched with an endless amount of contextual information
We can take this further by elaborating the Scenario class in Figure 3 with properties specifying the functions performed, their relative importance (e.g., required vs. desirable), and their performance attributes. But this does not necessarily help in comparing the results of the different studies. The Canterbury corpus, for example, is not defined in terms of use cases, and its classification of input files is quite unlike the EXI classification. They are really different ontologies. Simply aggregating them provides little insight into the significance of using one test corpus vs. another. A similar issue arises in representing the test results. Some of the studies we consulted present a set of curves—one per candidate—graphing compressed size against original size. But Augeri et al average the results over all test sets and present additional analysis of the test set attributes that were contributing factors [22]. Should these distinctions be modeled in the Test Results class of Figure 2? A further source of ambiguity is the instrumentation software itself. Different studies may yield different results in part because of different instrumentation software. A discussion in one of the EXI documents illustrates the issues:
Features Need Stories
61
The results presented here come from a stored snapshot that has been judged sufficiently stable for making decisions. Even so, there is still some variation in the results. This is a concern especially with the C-based candidates that may exhibit enormous and inexplicable variance between different test documents. It is therefore likely that there are still some problems with how the test framework's Java code interacts with the C code of the candidates. Accordingly, the results from the C-based candidates were filtered more carefully, by eliminating results for individual documents that were obviously incorrect. In addition, the stableness review of the results paid careful attention to any improvements in these candidates in particular. [24] We could address this by adding classes of instrumentation, linking them to the test results in a manner similar to Figure 2. But should we? There will always be important contextual information that has not been modeled, that could in principle be modeled, but that would be expensive to model. The alternative is to decorate the feature model with informal elaborations: commentary, explanation, and discussion. The relationships between the formal entities serve to coordinate these informal elaborations into a coherent story that answers questions of the form, Who, Why, What, and How.
5 Elaborating the Feature Model with Stories Deciding where to draw the line between formalization and informal elaboration must take account of the goals of the model. In our case study, the purpose of the elaborated feature model is to help us choose one of the alternatives listed in Table 2. So let us see how this plays out. Transmission speed being one of the criteria, we consult the Compactness feature, which is effectively equivalent to transmission speed. But Compactness cannot be summarized in a single value. Instead, from the Compactness feature of a given candidate, we can trace back along the indicates relationship in Figure 2 to see those test results that tell us something about this candidate’s level of success in compressing various inputs. There may be many such test results for this one candidate, including tests by different organizations or individuals, using different test sets, different methodologies, and different instrumentation. Each test result should point to this information. In the simplest case, a single candidate outperforms all the other candidates, i.e., it consistently produces the smallest output over all test sets in all of the recorded tests. In that case, we can easily say that this candidate scores highest with respect to transmission speed. But of course that is not likely. It is even less likely that we can also identify a clear second-place candidate, third-place candidate, etc., which we would like to do because transmission speed is only one of ten evaluation criteria. Instead, we have to start asking questions, the answers to which start to provide us with a coherent story. For example: • Which test sets (if any) resemble our expected data? • Are the results consistent for those test sets? • Is the provenance of the test results credible?
62
S.C. Bailin
If the answers to any of these questions are less than conclusive—for example, if we are uncertain whether any test set closely resembles our data, or the results are not consistent, or the provenance is doubtful—then we have to delve deeper, asking more questions: • • • •
What was the context of a test? Who did the test, and what do we know of their agenda? Was the methodology rigorous? What is the source of inconsistency between this and the tests from other sources?
The answers to such questions may or may not be found in the elaborated feature model shown in Figure 2 and Figure 3, depending on how far one takes the model elaboration. The questions, however, are definitely not modeled explicitly. This http://www.w3.org/TR/xbcproperties/#compactness
Feature
assessedBy
http://www.w3.org/T R/2009/WD-exievaluation-20090407/
http://www.w3.org/XML/EXI /public-status.html
performedBy Evaluation
Stakeholders
Method
Test Results
mayCauseRevisionOf
http://www.w3.org/TR/2009/WD-exievaluation-20090407/#compactnessresults
motivatedBy
employs
yields
Goals mayCauseRevisionOf
http://www.w3.org/TR/xbcmeasurement/
http://www.w3.org/2003/09/ xmlap/xml-binary-wgcharter.html
Fig. 4. By incorporating story tags in the elaborated feature model we can guide the potential re-user directly to relevant information
illustrates a common problem with ontologies: they may be rich in information, but they tend not to be self-explanatory. Many ontologies suffer from an absence of documentation about why the information is there, and how to use it. This is where stories enter, because the emphasis in a story is on rationale. The persistent question, Why? is what distinguishes a story from a mere report. For example, rather than just telling us that a particular test set was modeled on the Canterbury corpus, it would tell us why the Canterbury corpus was used. Without knowing this we cannot fairly assess whether the test results are relevant to our problem. More generally, we would like the elaborated feature model to guide us to the following types of information:
Features Need Stories
• • • • • •
63
Who are the stakeholders? What are they trying to achieve? Why? Why is it non-trivial—what barriers must they overcome? What did they do to overcome these barriers? Were they successful? Why? Did some barriers remain, or new ones appear?
The last three question may be iterated until, eventually, success (or, perhaps, failure) is declared. For example, the Compactness feature for EXI can point us to the URI for the EXI evaluation, which in turn points to earlier documents addressing the above questions. This is the skeletal structure of a story. But more than that is possible. The questions actually suggest an ontology of stories, consisting (for example) of actors, goals, barriers, actions, and rationales. Discussions about candidates for reuse can be marked up to indicate explicitly the actors, goals, barriers, etc. that have been involved in developing, using, and reusing the candidates. The feature model can use such markup to point us to the information we need. This is illustrated in Figure 4 for the Compactness feature of the EXI alternative.
6 Conclusion Feature models are a powerful way to achieve reuse in well established domains, such as those admitting of a product line architecture. But much reuse occurs in situations where there is no unified domain model; rather, the candidates for reuse and the available knowledge about them have varied provenance. In such situations, features are less well-defined, and their meanings need to be elaborated through additional context. Stories, by definition, are situated in context and emphasize rationale. They therefore provide an effective way of enriching a feature model with the necessary context. We have illustrated this through a case study involving the transmission of structured data between two systems.
References [1] Bailin, S.: Diagrams and design stories. Machine Graphics and Vision 12(1) (2003) [2] Bailin, S., Moore, M., Bentz, R., Bewtra, M.: KAPTUR: Knowledge acquisition for preservation of tradeoffs and underlying rationales. In: Proceedings of the Fifth Knowledge-Based Software Assistant Conference. Rome Laboratory (September 1990) [3] Kang, K., Cohen, S., Hess, J., Novak, W., Peterson, A.: Feature-Oriented Domain Analysis (FODA) Feasibility Study. Carnegie Mellon University Software Engineering Institute Technical Report CMU/SEI-90-TR-021 [4] van der Linden, F., Schmid, K., Rommes, E.: Software Product Lines in Action: The Best Industrial Practice in Product Line Engineering. Springer, Heidelberg (2007) [5] Bailin, S.: Software reuse as ontology negotiation. In: Bosch, J., Krueger, C. (eds.) Software Reuse: Methods, Techniques, and Tools. LNCS, vol. 3107, pp. 242–253. Springer, Heidelberg (2004)
64
S.C. Bailin
[6] Bailin, S., Simos, M., Levine, L., Creps, R.: Learning and Inquiry-Based Reuse Adoption (LIBRA). Wiley-IEEE Press (2000) [7] Abstract Syntax Notation: http://www.asn1.org [8] Sandoz, P., Triglia, A., Pericas-Geersten, S.: Fast Infoset, http://java.sun.com/developer/technicalArticles/xml/ fastinfoset/ [9] Ziv, J., Lempel, A.: A Universal Algorithm for Sequential Data Compression. IEEE Transactions on Information Theory 23(3), 337–343 (1977) [10] Efficient XML Interchange: http://www.w3.org/XML/EXI/ [11] Qing, X., Adams, C.: A comparison of compression techniques for XML-based security policies in mobile computing environments. In: Ottawa Workshop on New Challenges for Access Control (April 27, 2005) [12] Bzip: http://www.bzip.org/ [13] WAP Binary XML: http://www.w3.org/TR/wbxml/ [14] XML-binary Optimized Packaging: http://www.w3.org/TR/xop10/ [15] SOAP Message Transmission Optimization Mechanism: http://www.w3.org/TR/soap12-mtom/ [16] XMill: an Efficient compressor for XML, http://www.liefke.com/hartmut/xmill/xmill.html [17] Bournez, C.: Efficient XML Interchange Evaluation, W3C Working Draft (April 7, 2009), http://www.w3.org/TR/exi-evaluation [18] OASIS eXtensible Access Control Markup Language (XACML) TC, http://www.oasis-open.org/committees/ tc_home.php?wg_abbrev=xacml [19] Mundy, D.P., Chadwick, D., Smith, A.: Comparing the Performance of Abstract Syntax Notation One (ASN.1) vs. eXtensible Markup Language (XML). In: Terena Networking Conference 2008 / CARNet Users’ Conference 2008, Zagreb, Croatia (May 19-22, 2008) [20] Cokus, M., Winkiwski, D.: XML Sizing and Compression Study For Military Wireless Data, XML (2002) [21] XML Binary Characterization Use Cases: http://www.w3.org/TR/2005/NOTE-xbc-use-cases-20050331/ [22] Augeri, C.J., Bulutoglu, D.A., Mullins, B.E., Baldwin, R.O.: An Analysis of XML Compression Efficiency. In: Proceedings of the 2007 Workshop on Experimental Computer Science, San Diego, California (2007) [23] The Canterbury Corpus: http://corpus.canterbury.ac.nz/ [24] Efficient XML Interchange Measurements Note: http://www.w3.org/TR/2007/WD-exi-measurements-20070725/
An Optimization Strategy to Feature Models’ Verification by Eliminating Verification-Irrelevant Features and Constraints Hua Yan, Wei Zhang, Haiyan Zhao, and Hong Mei Key Laboratory of High Confidence Software Technology, Ministry of Education of China, Insititute of Software, School of Electronics Engineering and Computer Science, Peking University, Beijing, 100871, China {yanhua07,zhangw,zhhy}@sei.pku.edu.cn, [email protected]
Abstract. Feature models provide an effective approach to requirements reuse. One important problem related to feature models is the verification problem, which is NP-complete in theory. The existing approaches to feature models’ verification mostly focus on how to automate the verification of feature models using third-party’s tools, while these tools are usually designed to resolve general kinds of problems. However, by simply using these third-party’s tools, large-sized feature models still can hardly be verified within acceptable time. We argue that, to improve the efficiency of verification, the problem itself should be at first optimized. In this paper, we propose an optimization strategy to feature models’ verification, in which, verification-irrelevant features and constraints are eliminated from feature models and the problem size of verification is therefore reduced. We prove the correctness of this strategy, while experiments show the effectiveness of this strategy. Keywords: Feature model, Verification, Problem size, Reduction.
1 Introduction In software reuse, feature models provide an effective approach to modeling and reusing requirements in a specific software domain. The modeling responsibility of a feature model is achieved by encapsulating requirements into a set of features and clarifying possible dependencies among features. The reusing responsibility of a feature model is carried out through customization - that is, selecting a subset of features from a feature model, while maintaining those constraint dependencies among features. One important problem related to feature models’ customization is the verification problem. The verification of a feature model has two purposes. Before customization, the verification aims to find possible conflicts in constraints among features. After customization, the verification is intended to find possible conflicts in customizingdecisions on a feature model. Based on the discovery that constraints among features can be formalized as propositional formulas [4,7,1], the verification of a feature model can be formalized correspondingly as a set of propositional satisfiability (SAT) S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 65–75, 2009. © Springer-Verlag Berlin Heidelberg 2009
66
H. Yan et al.
problems, which are NP-complete in general. Because of the NP-complete nature, the verification of a complex feature model inevitably suffers from the state space explosion problem. For example, for a feature model with 1000 features and many complex constraints, the state-space of the verification problem is as large as 21000. Therefore, it is often infeasible to verify complex feature models without adopting any optimization strategy. In the existing research on feature models’ verification, most of them focuses on how to automate the verification of feature models using third-party’s tools (such as those SAT-solvers, CSP-solvers, and Model Checkers). However, as far as to our knowledge, very little work focuses on how to optimize the verification of feature models based on the characteristics of feature models’ verification (except some of our previous work [7,8]). Since those third-party’s tools are often designed to resolve general kinds of problem, it is impossible for them to incorporate any optimization strategy specific to feature models’ verification. In this paper, we propose an optimization strategy to feature models’ verification by eliminating verification-irrelevant features and constraints from feature models, and prove the correctness of this strategy. This strategy is developed based on the observation that most feature models contain some features and constraints that are irrelevant to feature models’ verification (in the sense that these verification-irrelevant features and constraints can be safely removed without changing the results of feature models’ verification), while the problem size of a feature model’s verification is exponential to the number of features and constraints in the feature model. Therefore, eliminating verification-irrelevant features and constraints from feature models will reduce the problem size of verification, and alleviate the state space explosion problem. Experiments have shown that this strategy improves the efficiency of and the capability to feature models’ verification. The rest of this paper is organized as follows. Based on some preliminary knowledge introduced in Section 2, Section 3 presents the optimization strategy to feature models’ verification, and gives its correctness proof. Experiments and analysis are shown in Section 4. Related works are discussed in Section 5. Finally, Section 6 concludes this paper with a short summary.
2 Preliminary In this section, we first give a notation for feature models with formal semantics of constraints among features, and clarify two kinds of constraint in feature models according to the source of constraints, and then introduce the criteria for feature models’ verification, which are proposed in our previous research [7]. 2.1 A Notation for Feature Models The symbols in this notation are listed in Table 1 and explained from the viewpoint of customization. The formal definitions of constraints among features are given in Table 2 and Table 3.
An Optimization Strategy to Feature Models’ Verification
67
Table 1. Symbols in the notation for feature models Symbol
Name
Explanation
A mandatory named “X”.
feature A mandatory feature must be selected in a customizing result,
X
An optional named “Y”.
feature
Y
if its parent feature is selected or it hasn’t a parent feature. If its parent is removed, it must be removed. An optional feature can either be selected in or be removed from a customizing result, if its parent feature is selected or it hasn’t a parent. If its parent is removed, it must be removed. A refinement connects two features. The feature connecting to the non-arrow end is called the parent of the other feature. A feature can only have one parent feature at most. A requires constraint connects two features. The feature connecting to the non-arrow end is called the requirer, and the other the requiree. This constraint means that if the requirer is selected, the requiree must be selected. An excludes constraint connects two features. This constraint means that the two features should not be both selected in a same customizing result. The left end connects to a composite constraint or to one of the right ends of a binding predicate. The right ends connect to a set of features or binding predicates. We define three types of binding predicate: and (denoted by ∧); or (denoted by ∨); xor (denoted by 1). See Table 2 for the formal definition of binding predicates. We define two types of composite constraint: requires (de); excludes (denoted by ). See Table 3 for noted by their formal definitions.
A refinement relation between two features. A requires constraint between two features. An excludes constraint between two features.
type
type
A binding predicate among a set of features and binding predicates A composite constraint between two binding predicate
Table 2. The formal definitions of binding predicates. In this table, A and B denotes features, and p and q denotes binding predicates. For a feature F, bind(F) is a predicate; it is true if F is selected, false otherwise. In our notation, we only use binding predicates as constituent parts of the composite constraints, but not as individual constraints. or(A, …, B, …, p, …, q)
Binding Predicate
type
A
type
A
p
bind(A)∨...∨¬bind(B) ∨...∨p∨...∨¬q
type
A
B
q
xor(A, …, B, …, p, …, q)
type
type
B
p
Formal Definition
and(A, …, B, …, p, …, q)
p
q
bind(A)∧... ∧¬bind(B) ∧...∧p∧...∧¬q
type
B
q
bind(A)⊗... ⊗¬bind(B) ⊗...⊗p⊗...⊗¬q
Table 3. The formal definitions of composite constraints. In this table, p and q denotes binding predicates. In the situation that p and q only contains one feature, the two types of composite constraints becomes the requires and the excludes constraints between two features. Composite Constraint Formal Definition
requires(p, q) p
type
type
p→q
excludes(p, q) q
p
type
type
p → ¬q
q
68
H. Yan et al.
2.2 Implicit Constraints and Explicit Constraints Constraints in feature models can be classified into two kinds according to their source. The first kind is the implicit constraints that are imposed by refinements relations between features. In feature models, each refinement relation implicitly imposes a requires constraint between the involved two features – that is, the child feature requires the parent feature. The second kind is the explicit constraints that are explicitly added into feature models by model constructors. Figure 1 shows a feature model example, in which, (a) is the refinement view, consisting of features and refinements between features, and (b) is the constraint view, consisting of those explicit constraints added by model constructors. Figure 1(c) shows all the constraints in the form of propositional formulas. The constraints from 1 to 6 are implicit constraints derived from the refinement view, and the constraints from 7 to 8 are explicit constraints. B
A
G
1. 2. 3. 4. 5. 6.
G
8.
F
D B
C
F
D
G
(a) Refinement view of the feature model
E
E B
(b) Constraint view of the feature model
bind(B) bind(C) bind(D) bind(E) bind(F) bind(G)
bind(A) bind(A) bind(A) bind(A) bind(C) bind(C)
7. ( bind(B) bind(D) bind(E) ) ( bind(F) bind(G) ) bind(B) bind(G) (c) Propositional formula view of the feature model
Fig. 1. A feature model example with explicit and implicit constraints
2.3 Three Criteria for Feature Models’ Verification In our previous research [7], we proposed three criteria for feature models’ verification. According to the deficiency framework for feature models [10], the three criteria can detect all the anomaly and inconsistency deficiencies. Due to space limitation, we just list the three criteria as follows without further explanations. 1. There exists at least a set of customizing decisions to all undecided features in a feature model that will not violate any constraints in the feature model. 2. Each undecided feature in a feature model has the chance to be selected without violating any constraints in the feature model. 3. Each undecided feature in a feature model has the chance to be removed without violating any constraints in the feature model. More information about what kinds of deficiencies exist in feature models and how the three criteria detect these deficiencies can be referred to literature [10] and [7].
3 Eliminating Verification-Irrelevant Features and Constraints In this section, we present the optimization strategy to feature model’s verification, and give the correctness proof of this strategy.
An Optimization Strategy to Feature Models’ Verification
69
3.1 The Optimization Strategy During feature models’ verification, one kind of errors (called implicit constraint violations) can be easily detected and fixed at first. This kind of errors occurs when a child feature is selected while its parent is not. By checking the binding states of two features in each refinement, implicit constraint violations can be detected. Then, these violations can be fixed by removing all the offspring features of the removed features and selecting all the ancestor features of the selected features. We have observed that certain features and constraints are irrelevant to the verification after handling implicit constraint violations. That is, these features and constraints can be safely eliminated without changing the verification results. Based on this observation, we develop an optimization strategy to feature models’ verification. This strategy is based on the following two concepts. Definition 1. Verification-irrelevant features. A feature is verification-irrelevant, iff this feature does not appear in any explicit constraint, and none of its offspring features appears in any explicit constraint. Definition 2. Verification-irrelevant constraints. A constraint is verification-irrelevant, iff at least one feature involved in this constraint is verification-irrelevant. Figure 2 shows the verification-irrelevant features and constraints in a feature model example. After eliminating these verification-irrelevant features and constraints, this feature model is reduced to the feature model in Figure 1.
A B B
C
D
F
E D
G I1
F
G
I2
I3
I4
I5
I6
I7
I8
(a) Refinement view of the feature model
E B
G
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14.
15. ( bind(B) ( bind(F) bind(B)
16. (b) Constraint view of the feature model
bind(B) bind(C) bind(D) bind(E) bind(F) bind(G) bind(I1) bind(I2) bind(I3) bind(I4) bind(I5) bind(I6) bind(I7) bind(I8)
bind(A) bind(A) bind(A) bind(A) bind(C) bind(C) bind(B) bind(E) bind(E) bind(F) bind(F) bind(F) bind(I2) bind(I2) bind(D) bind(E) ) bind(G) ) bind(G)
(c) Propositional formula view of the feature model
Fig. 2. A feature model example. The verification-irrelevant features and constraints are shown in the grey area. There are 8 verification-irrelevant features (I1 to I8 in (a)) and 8 verificationirrelevant constraints (7 to 14 in (c))
Based on the above two definitions, the optimization strategy can be expressed as follows. Given a feature model without implicit constraint violations, eliminating those verification-irrelevant features and constraints from this feature model will not influence the verification result of this feature model.
70
H. Yan et al.
Following this strategy, we can deduce that the feature model in Figure 2 and the one in Figure 1 are equivalent from the verification point of view if the feature model in Figure 2 contains no implicit constraint violations. 3.2 The Correctness Proof We prove the correctness of this strategy by two theorems. In the first theorem, we show that, after handling implicit constraint violations, if the reduced feature model satisfies the three verification criteria, the original feature model will also satisfy these criteria. To prove this theorem, three lemmas are first introduced. In the second theorem, we show that, if the original feature model satisfies the three verification criteria, the reduced feature model will also satisfy them. Based on the two theorems, the correctness of this strategy can be naturally deduced. In the following, we use two pairs and to denote the original feature model and the reduced feature model, respectively. In the two pairs, F and F’ denote the feature sets of the two feature models, and C and C’ denote the constraint sets. In addition, we use to denote the feature model consisting of the feature set F and the set of verification-irrelevant constraints C−C’ being removed from the original feature model. The three verification criteria (see Section 2.3) on a feature model x are denoted by VerifyC1(x), VerifyC2(x) and VerifyC3(x), respectively. The conjunction of the three criteria is denoted by Verify(x).
∧
Lemma 1. ├ (VerifyC1() VerifyC1()) → VerifyC1() Proof: After handling implicit constraint violations, VerifyC1() is true, then, the assignment of F’ can be expanded to the assignment of F by giving each undecided eliminated feature a removing customizing decision, which will not cause any conflict.
∧
Lemma 2. ├ (VerifyC2() VerifyC2()) → VerifyC2() Proof: Model reusers can select all the undecided eliminated features without violating any constraint.
∧
Lemma 3. ├ (VerifyC2() VerifyC2()) → VerifyC2() Proof: Model reusers can remove all the undecided eliminated features without violating any constraint. Theorem 1. Verify() ├ Verify() → Verify() Proof: We can deduce from Lemma 1, Lemma2 and Lemma 3 that ├ (Verify() Verify())→Verify()) Thus, ├ (Verify() Verify())→Verify()) Verify() Verify () ├ Verify () Verify() ├ Verify() → Verify()
∧
⇒ ⇒
∧
∧
Theorem 2. ├ Verify()→Verify() Proof: F’ F, C’ C ├ Verify() → Verify()
⊆
⊆
⇒
Corollary. Verify() ├ Verify() ↔ Verify()
An Optimization Strategy to Feature Models’ Verification
71
4 Experiments In this section, we first introduce an algorithm of generating random feature models, and then apply our optimization strategy to the verification of a set of randomly generated feature models to demonstrate the effectiveness of this strategy. 4.1 An Algorithm of Generating Random Feature Models as Test Cases To provide test cases for our experiments, we design an algorithm of generating random feature models (see Algorithm 1). Algorithm 1. An algorithm of generating random feature models. In this algorithm, GetRandomInt(n) is a function that returns a random integer from 0 to n. Input:
fN cN mNC mW
: : : :
p
:
The number of features of the feature model. The number of explicit constraints of the feature model. The maximum number of features in the constraints. The maximum number of children of a feature. Its default value is 10. The percentage of verification-irrelevant features in the feature model. Its default value is -1, which means that the percentage of verification-irrelevant features is random.
Output: The random generated feature model generate_random_fm(int fN,int cN,int mNC,int mW=10,int p=-1){ FeatureModel fm = new FeatureModel(); Queue queue = new Queue(); Feature f = new Feature(); queue.push(f); int counter = 1; while(!queue.isEmpty()){ Feature parent = queue.pop(); for(int i = 0; i < GetRandomInt(mW); i++){ Feature child = new Feature(); parent.addChild(child); fm.featureSet.add(child); counter++; if (p != -1 && counter <= (1-p)*fN){ Constraint constraint = new constraint(child,parent,“requires”); fm.addExplicitConstraint(constraint); } if (counter == fN) break L; } } L:for(int i = 0; i < cN; i++){ Set source = new Set(), target = new Set(); for(int i = 0; i
72
H. Yan et al.
It should be noticed that in a feature model generated by Algorithm 1, all features are optional. This is because that, in our experiments, we assume feature models have been optimized by the atomic-set technique proposed in our previous research [7]. By applying this technique, mandatory features can be eliminated from feature models. 4.2 Experiments and Analysis To make the experiments reflect the effectiveness of our strategy for feature models with different complexity, we generate three groups of feature model by varying the parameters of Algorithm 1. We use a BDD-based feature models’ verifier [8] to verify the optimized feature models. The environment for our experiments is a computer with an Intel Core DUO 2.66GHz CPU, 2GB of memory and a Windows XP OS. without eliminating verification-irrelevant features and constraints
Time (Second) 62.7 60 53.5 48.5
50
after eliminating verification-irrelevant features and constraints
38.1
40 30
25.2 19.2
20
15.0 10 0
7.6 10
20
30
40
50
60
70
6.0
80 Percentage of verification-irrelevant features (%)
Fig. 3. Experiment results of the first group of test cases. This group has 9 feature models. All of them contain 500 features and 50 explicit constraints, and the percentage of verificationirrelevant features varies from 0% to 80% with an increment of 10%.
∞ ∞
Time (Second)
+
+
60
56.9
50 43.9
40 30
without eliminating verification-irrelevant features and constraints after eliminating verification-irrelevant features and constraints
20 17.0 10
7.5 1.1
0
0.3 0.1 100 200 300 /10 /20 /30
3.8 400 /40
500 /50
600 /60
700 Number of Features /70 /Number of Explicit Constraints
Fig. 4. Experiment results of the second group of test cases. This group has 7 feature models. The number of features in each test case varies from 100 to 700 with an increment of 100, the number of explicit constraints in each test case varies from 10 to 70 with an increment of 10, and the percentage of verification-irrelevant features is random.
An Optimization Strategy to Feature Models’ Verification
73
Figure 3 shows the experiment results of the first group, from which we can see that our strategy improves the efficiency of verification for this group of test cases. Moreover, our strategy becomes more effective as the percentage of verificationirrelevant features increases. Figure 4 shows the experiment results of the second group. We can see that although both of the solid curve and the dashed curve rise as the number of features and explicit constraints increases, the growth rate of solid curve is lower than that of the dashed curve, which means that our strategy decreases the time for feature models’ verification. The experiment results also show that, for this group of test case, our strategy increases the capability to feature models’ verification. Time (Second)
+
60 50
whiout eliminating verification-irrelevant features and constraints
40
42.2
∞
∞
+
after eliminating verification-irrelevant features and constraints
30 23.3 20
13.9
9.7
10 0
16.1
15.6 6.0
5.0
8.2
4.2 4.7 3.2 2.5 3.0 2.2 1.3 0.3 0.8 1.9 0.2 0.1 0.1 0.3 0.1 100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 /20 /30 /32 /34 /36 /38 /40 /42 /44 /46 /48 /50 /52 /54 /56 /22 /24 /26 /28 Number of Features /Number of Explicit Constraints
Fig. 5. Experiment results of the third group of test cases. This group has 19 feature models. The number of features in each test case varies from 100 to 1900 with an increment of 100. The number of explicit constraints in each test case varies from 20 to 56 with an incremental change of 2. The percentage of verification-irrelevant features is random.
Figure 5 shows the experiment results of the third group. We can see that, by applying our strategy, a feature model that contains 1500 features can be verified within 10 seconds. For this group of test cases, this strategy improves both the capability to and the efficiency of feature models’ verification.
5 Related Work The verification problem of feature models has been noticed since the first time feature models are proposed [3]. Existing research on feature models’ verification can be classified into three categories: specification and formalization of verification criteria, formalization of feature models, and automation of verification. In the research on specification and formalization of verification criteria, der Maßen and Lichter [10] proposed a deficiency framework of feature models. In our previous work [7], we proposed three formalized verification criteria. Our investigation [9] shows that the three criteria can detect all kinds of anomaly and inconsistency deficiency in der Maßen and Lichter’s deficiency framework. In the research on formalization of feature models, Mannion [4] proposed a first-order logic based method for the
74
H. Yan et al.
formalization of feature models’ constraints. In [7], we classified constraints in feature models into several types, and clarified their formal semantics based on propositional logic. In the research on automation of verification, several verification methods using third-party’s tools are proposed. For example, Batory proposed a LTMS-based method [1]. In Czarnecki’s research [2], a commercial BDD package is used. White et al. proposed a CSP-Solver-based approach [6]. However, little existing research has addressed how to optimize feature models’ verification at the problem level. One exception is the atomic-set technique proposed in our previous work [7]. Segura gave a quantitative analysis to the effectiveness of the atomic-set technique [5]. The strategy proposed in this paper can be integrated with the atomic-set technique through sequential composition. That is, a feature model can be first reduced by the atomic-set technique, and then be further reduced through the strategy in this paper. Furthermore, these two optimization techniques can also be seamlessly integrated with the existing approaches to feature models’ verification by equipping these approaches with a preprocessing of optimization.
6 Conclusions In this paper, we proposed an optimization strategy to feature models’ verification, and proved the correctness of this strategy. This strategy provides a way to eliminate features and constraints that are irrelevant to feature models’ verification. Experiment results demonstrate that by applying this strategy, the verification efficiency of feature models is improved, and the verification capability is enhanced as well. Acknowledgments. This work is supported by the National Grand Fundamental Research 973 Program of China under Grant No. 2009CB320701, the Science Fund for Creative Research Groups of China under Grant No. 60821003, the Hi-Tech Research and Development Program of China under Grant No. 2006AA01Z156, and the Natural Science Foundation of China under Grant No. 60703065 and 60873059.
References 1. Batory, D.: Feature Models, Grammars, and Propositional Formulas. In: Obbink, H., Pohl, K. (eds.) SPLC 2005. LNCS, vol. 3714, pp. 7–20. Springer, Heidelberg (2005) 2. Czarnecki, K., Kim, C.H.P.: Cardinality-Based Feature Modeling and Constraints: A Progress Report. In: OOPSLA 2005 International Workshop on Software Factories (2005) 3. Kang, K.C., Cohen, S.G., Hess, J.A., Novak, W.E., Peterson, A.S.: Feature-Oriented Domain Analysis Feasibility Study. Technical reports, Software Engineering Institute, Carnegie Mellon University (1990) 4. Mannion, M.: Using First-Order Logic for Product Line Model Validation. In: Chastek, G.J. (ed.) SPLC 2002. LNCS, vol. 2379, pp. 176–187. Springer, Heidelberg (2002) 5. Segura, S.: Automated Analysis of Feature Models using Atomic Sets. In: Workshop on Analyses of Software Product Lines, in Conjunction with the 12th Software Product Line Conference (2008) 6. White, J., Benavides, D., Schmidt, D.C., Trinidad, P., Ruiz-Cortés, A.: Automated diagnosis of product-line configuration errors in feature models. In: Proceedings of the 12th Software Product Line Conference (2008)
An Optimization Strategy to Feature Models’ Verification
75
7. Zhang, W., Zhao, H., Mei, H.: A Propositional Logic-Based Method for Verification of Feature Models. In: Proceedings of 6th International Conference on Formal Engineering Methods, pp. 115–130 (2004) 8. Zhang, W., Yan, H., Zhao, H., Jin, Z.: A BDD-Based Approach to Verifying CloneEnabled Feature Models’ Constraints and Customization. In: Mei, H. (ed.) ICSR 2008. LNCS, vol. 5030, pp. 186–199. Springer, Heidelberg (2008) 9. Zhang, W., Mei, H., Zhao, H.: Feature-Driven Requirements Dependency Analysis and High-Level Software Design. Requirements Engineering Journal 11(3), 205–220 (2006) 10. von der Maßen, T., Lichter, H.: Deficiencies in feature models. In: Workshop on Software Variability Management for Product Derivation, in Conjunction with the 3rd Software Product Line Conference (2004)
Reusable Model-Based Testing Erika Mir Olimpiew and Hassan Gomaa Department of Computer Science George Mason University, Fairfax, VA [email protected], [email protected]
Abstract. A reusable model-based testing method for software product lines (SPL) is used to create test specifications from use case and feature models, which can then be configured to test individual applications that are members of the SPL. This paper describes a feature-oriented model-based testing method for SPLs that can be used to reduce the number of reusable test specifications created to cover all use case scenarios, all features, and selected feature combinations of a SPL. These test specifications can be automatically selected and configured during feature-based test derivation to test a given application derived from the SPL. This paper also addresses what application configurations to test and how to configure test specifications for these applications. This model-based testing method was applied and evaluated on two SPL case studies. Keywords: Reuse, model-based testing, requirements, software product lines, feature model, use case model, activity diagrams, decision tables.
1 Introduction Reusable software requirement models help to minimize redundancy and inconsistency in an application’s requirements. Reusable software requirement models are used in a Software Product Line to proactively design a family of applications with similar characteristics, in order to reuse common features across the members of a SPL and also to distinguish between the features, or requirements, that differentiate these applications [1]. Reusable requirements model-based testing describes how to create reusable test specifications from an application’s requirement models, such as use case and feature models. In a SPL, these concepts are extended to enable the systematic reuse of test specifications across the members of the SPL. Several use case-based approaches have been developed to systematically create reusable test specifications for a SPL [2, 3, 4] For some evolving and customizable SPLs, which have a large number of features and possible application configurations, model-based testing for SPLs describes the combinations of features that should be selected to describe a set of application configurations to test [5, 6]. For example, a family of mobile phone applications can have several optional features, such as call waiting, and text messaging, which can be individually selected and configured on-demand for a customer. A possible test strategy would be to select a set of application configurations that covers all combinations of S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 76–85, 2009. © Springer-Verlag Berlin Heidelberg 2009
Reusable Model-Based Testing
77
optional features with basic phone capabilities. However, in practice, it may be impractical to test all combinations of features. This paper builds on previous research by describing a comprehensive modelbased testing method for SPLs, which combines feature-oriented testing with a use case-oriented test method to derive reusable test specifications. The test coverage criterion for this method is to cover all use-case scenarios and all features, as well as selected feature combinations including all feature dependencies and feature interactions. This paper expands on earlier research [7]. During application derivation, the reusable test specifications are customized for each application configuration. Applying this model-based testing method can reduce the number of reusable test specifications that need to be created to cover all use case scenarios, all features, and selected feature combinations of a SPL. The paper is organized as follows. Section 2 describes related work; section 3 describes CADeT, a feature-oriented model-based testing method for SPLs. Section 4 describes the results of validating the testing method. Section 5 contains the conclusions and further study.
2 Related Research 2.1 Software Product Lines Sofware Product Line development consists of SPL engineering and application engineering (Fig. 1). Model-based SPL engineering consists of the development of requirements, analysis and design models for a family of systems that comprise the application domain. During application engineering, an application configuration is derived from the SPL, which includes all the common features and selected optional and alternative features. The requirements, analysis, and design models, as well as component implementations, are also customized based on the features selected for that application. Any unsatisfied requirements, errors and adaptations are addressed iteratively in SPL engineering. Product Line UML-Based Software Engineering (PLUS) is a feature-based multiple-view modeling design method for software product lines. In the Requirements phase of SPL engineering, PLUS uses feature modeling to model variability and use case modeling to describe the SPL functional requirements [1]. The emphasis in feature modeling is in characterizing the SPL variability, as given by optional and alternative features, since these features differentiate one member of the family from the others. Use cases, on the other hand, are a means of describing the functional requirements of an SPL. The relationship between features and use cases is explicitly modeled by a feature/use case dependency table. A feature model [8] distinguishes between the members of the SPL in terms of their commonality (expressed as common features) and variability (optional and alternative features), feature dependencies, and feature groups that define constraints in combining features.
78
E. Mir Olimpiew and H. Gomaa
Product Line Requirements
Product Line Requirements and Analysis Models, Product Line Software Architecture, Customizable Test Models Software Product Line Engineering
Software Product Line Repository
Application Requirements
Software Application Engineering
Application Engineer
Executable Application
Customer
Unsatisfied Requirements, Errors, Adaptations
Fig. 1. SPL development processes
2.2 Model-Based Testing Model-based testing creates test specifications from formal or semi-formal software models of a software application. Use case-based testing methods have been extended for a SPL in [2, 3, 4]. Reuys et al [4] developed the ScenTED technique (Scenario-based TEst case Derivation), where test specifications are traced from the activity diagrams of a SPL to satisfy the branch coverage testing criterion, and then customized for an application derived from the SPL. Other software models, such as a decision tree, have also been used to apply systematic reuse to the test assets of a SPL. Geppert et al [9] re-engineer a legacy system test suite and then use a decision tree to configure this test suite for an application of the SPL. McGregor first introduced the problem of selecting representative application configurations to test from the potentially large configuration space of an SPL using combinatorial testing techniques [5]. Scheidemann [6] describes a method of selecting a minimal set of representative configurations, such that successful verification of this set implies the correctness of the entire SPL.
3 The CADeT Approach Customizable Activity Diagrams, Decision Tables and Test Specifications (CADeT) is a feature-oriented model-based functional test design method for SPLs. CADeT is incorporated within the PLUS method described above. CADeT can also be integrated with other SPL development methods that use both feature and use case models to describe the SPL requirements. CADeT extends PLUS to create activity diagrams and decision tables from the use case and feature models of a SPL. The decision tables are used to generate reusable, functional system test specifications for a SPL. Fig. 2 shows how CADeT (shaded in gray) is integrated with the PLUS method [1]. During SPL engineering, PLUS is used to create feature and use case requirements models, and CADeT is used to develop customizable activity diagrams, decision tables, and test specifications from these
Reusable Model-Based Testing
79
models. During application engineering, PLUS is used to derive one or more applications from the SPL, and CADeT is used to select and customize the test specifications for each application. Each derived application is then tested using the test specifications derived using the same feature model.
Fig. 2. Impact of CADeT on PLUS
In Fig. 2, SPL Test Modeling consists of creating activity diagrams from use cases to provide greater precision in the use case descriptions, creating decision tables to formalize the test specifications, and defining a feature based test plan that provides test coverage of all use case scenarios, all features, and selected feature combinations of a SPL. Feature-based Test Derivation consists of deriving the test specifications for the derived application, selecting the test data, and testing the application. The following sections describe these steps in more detail. 3.1 SPL Engineering: Create Activity Diagrams Functional models, such as activity diagrams, can be used to make the sequencing of activities in a use case description more precise for analysis and testing. Decision points identify where alternative scenarios diverge from the main scenario. An activity diagram is developed from each use case description in the use case model, and then activities in the activity diagrams are associated with the features in the feature model. An activity node can be used to represent different granularities of functional variations, ranging from a fine granularity of functional variation, such as a parameter in a use case step, to a coarse granularity of functional variation, such as a set of use cases. Further, fine-grained functional variations tend to be dispersed and repeated across the use case activity diagrams of a SPL, while coarse-grained variations are represented by an entire use case activity diagram, or a group of use case activity diagrams. Thus, managing fine-grained variability requires more sophisticated techniques to group related functions and to minimize redundancy. CADeT uses UML stereotypes to distinguish between different granularities of functional variability in the activity
80
E. Mir Olimpiew and H. Gomaa
diagrams of a SPL, and feature conditions to relate this variability to features in the feature model. Some of the following stereotypes are used in an activity node to distinguish between different levels of functional abstraction: • • • •
A «use case» activity node, which describes a use case. An «extension use case» activity node, which describes an extension use case. An «input step», which describes an input event from an actor to an application in a use case description. An «output step», which describes an output event from an application to an actor in a use case description.
The feature to use case relationship table of PLUS [1] is used together with reuse stereotypes and feature conditions of CADeT to analyze the impact of common, optional, and alternative features on the activity diagrams. A feature to relationship table associates a feature with one or more use cases or variation points, where a variation point identifies one or more locations of change in the use cases. A reuse stereotype is a UML notation that classifies a modeling element in a SPL by its reuse properties [1]. CADeT reuse stereotypes are applied to activity nodes rather than decision nodes as in [4], since activity nodes can be abstracted or decomposed to represent different levels of functional granularity. CADeT contains the following reuse stereotypes to describe how an activity node is reused in the applications derived from the SPL: • • • •
A «kernel» activity node, which corresponds to a «common» feature in the feature model. An «optional» activity node, which corresponds to an «optional» feature in the feature model. A «variant» activity node, which corresponds to an «alternative» feature in the feature model. An «adaptable» activity node, which identifies an activity node that is associated with a use case variation point.
Besides reuse stereotypes, feature conditions are added to associate the variability in the control flow of an activity diagram with a feature in a feature model. The values of a feature condition represent possible feature selections. An optional feature in the feature model is associated with a Boolean feature condition with two possible values. An alternative feature in the feature model is associated with a feature condition that represents its feature group, where each alternative is a possible value for that feature condition. Setting the value of a feature condition enables or disables the activities associated with the feature in the activity diagram of an application derived from the SPL. Banking System SPL example A Banking System SPL provides ATM services and optional online services to its customers. The banking system SPL can be used to derive a configuration of a banking application that provides ATM services only, or an application that provides both ATM and online services. In addition, a banking application can be configured for different languages, pin formats, and maximum number of pin attempts (Fig. 3).
Reusable Model-Based Testing
81
Fig. 3. Banking System SPL feature model «adaptable use case» 1 Validate pin
«localPrecondition» ATM.state = Idle
«adaptable output step» 1 Display welcome message (vpLanguage , vpGreeting )
«kernel input step» 2 Insert card
«adaptable aggregate step» 3 Process pin input
«localPrecondition» ATM.state = WaitingForPin
«adaptable output step» 3.1 Prompt for pin (vpLanguage ) «kernel output step» 6 Eject card «adaptable input step» 3.2 Enter pin (vpPinFormat )
«adaptable output step» 3.3 Display error message and reprompt (vpLanguage )
[(NOT ValidPin) AND (numAttempts >= maxAttempts)]
[(NOT ValidPin) AND (numAttempts < maxAttempts)]
[ValidPin AND (numAttempts <= maxAttempts)] «adaptable output step» 4 Prompt for transaction type (vpLanguage )
«adaptable output step» 5 Display max attempts error (vpLanguage )
«localPostcondition» ATM.state = WaitingForTransaction
Fig. 4. Activity diagram for Validate Pin kernel use case
Table 1 shows the feature conditions and feature selections associated with features of the Banking System SPL. Fig. 4 shows a simplified activity diagram created from the Validate Pin kernel use case description. The Spanish, French and English language features correspond to the vpLanguage variation point in the feature to use case relationship table, which impacts all output steps in the activity diagram of Fig. 4. Each of these activity nodes is stereotyped as «adaptable», and each references
82
E. Mir Olimpiew and H. Gomaa
another sub-activity diagram that shows the feature conditions, feature condition values, and variant display prompts associated with the Spanish, French and English language features (Fig. 5).
Fig. 5. A sub-activity diagram for a display prompt adaptable output step Table 1. Feature conditions of Banking System SPL
Feature condition BankingSystemKernel onlineBanking Language pinFormat maxAttempts
Feature selections T {T, F} {English, Spanish, French} [3..10] [1..5]
3.2 SPL Engineering: Create Decision Tables and Test Specifications In CADeT, decision tables are used to represent and organize the associations between features and test specifications created to cover the use case scenarios in a SPL. A decision table is created from each activity diagram in the SPL so that test specifications can be associated with each use case scenario. The precondition, feature conditions, execution conditions, postconditions, and activity nodes of an activity diagram are mapped to condition rows in the decision table. Simple paths are traced from an activity diagram for each use case scenario and then mapped to a reusable test specification in a column in the decision table. A simple path is a sequence of unique, non-repeating activity nodes traced from an activity diagram. A simple path begins at a precondition or postcondition, and ends at the next precondition or postcondition state in the activity diagram. Each simple path is mapped to a reusable test specification in a column in the decision table. A feature can be associated with a test specification created for a use case scenario, which represents a unit of coarse-grained functionality, or a feature can be associated with a variation point in that test specification, which represents a unit of fine-grained functionality. As in an activity diagram, a variation point in a test specification in a decision table is represented using the «adaptable» stereotype.
Reusable Model-Based Testing
83
CADeT distinguishes between the binding times of coarse-grained functional variability (feature to test specification) and fine-grained variability (feature to variation point). The feature selections of feature conditions associated with test specifications are bound during SPL engineering, while the feature selections of feature conditions associated with variation points are bound during feature-based test derivation. Delaying the binding of the fine-grained variability improves the reusability of the test specifications by reducing the number of test specifications that need to be created and maintained for a SPL. The simplified decision table for the Validate Pin use case contains four test specifications that correspond to simple paths (columns) traced from the activity diagram in Figure 5 for three use case scenarios: an initialization sequence {1, 2}; a valid pin scenario {3.1, 3.2, 4}; an invalid pin < max pin attempts scenario {3.1, 3.2, 3.3}; and an invalid pin >= max pin attempts scenario {3.1, 3.2, 5, 6}. The numbers correspond to the numbers of the activity nodes in Fig. 4, and each simple path begins at a precondition/postcondition and ends at another precondition/precondition. This allows simple paths to be concatenated to form more complex test sequences. Further, each simple path contains customizable <> “Display” or “Prompt” nodes, which are impacted by the alternative English, French, and Spanish language features. These nodes will be customized during application engineering when one of the language features is selected for an application derived from the SPL. 3.3 SPL Engineering: Define Feature-Based Test Plan Next, a test plan is created to describe a set of application configurations to test that will cover all features, selected feature combinations and all use case scenarios of a SPL. First, the feature model is analyzed to limit the number of application configurations to test. Feature dependencies, such as one feature requires another feature, must be tested together. Feature grouping constraints, such as mutually exclusive group, limit the number of possible feature combinations in a SPL. Parameterized features describe a range of values, which must be defined during application derivation. The boundary-value test selection criterion can be applied to select discrete values for the parameterized features of a SPL. A feature interaction is a functional behavior that is enabled for a feature combination selected for an application derived from the SPL, but that is not enabled when any feature of the combination is selected separately. In an activity diagram, a feature interaction is represented as an activity or data value that is enabled by a combination of two or more features, but is not enabled when any feature of the combination is selected separately. Test specifications correspond to simple paths in an activity diagram, which can be analyzed to detect feature interactions. A feature interaction exists in a test specification if that specification is impacted by more than one feature, and if the combination of features enables a test step that is not enabled when any feature of the combination is selected separately. Combinatorial testing techniques for single applications [10] are extended for SPLs by applying the notion of a configuration parameter with possible parameter values to a feature condition with possible feature selections. The largest number of feature combinations to test is used to determine a minimum n-way feature-based combinatorial coverage criterion for that SPL, where an n-way combinatorial coverage criterion covers combinations of at most n features.
84
E. Mir Olimpiew and H. Gomaa
An example of a feature-based test plan is shown for the simplified Banking System SPL in Fig. 3. The SPL in Fig. 3 has a total of 7 features: one common feature, the Banking System Kernel; one optional Online Banking feature; three alternative features, English, Spanish, and French, which are part of an exactly-one-of Language feature group; and two parameterized features, Pin Format, and Pin Attempts. The total number of possible feature combinations is 240=1 x 2 x 3 x 8 x 5. All test specifications created for the use cases associated with the Banking System Kernel and optional Online Banking feature are impacted by the language features. Each combination of a language feature with the Banking System Kernel and optional Online Banking feature enables language-specific display prompts and output test steps for that feature. Thus, at least a 2-way combinatorial testing criterion is needed to generate a set of applications to test that will cover all 2-way feature combinations. 3.4 Application Engineering: Derivation of Test Specifications Next, the test specifications of the SPL are customized for each representative application using several custom tools. A test generator tool is used to select and configure the test specifications based on the feature selections for an application configuration, and create a test specification document that contains the test specifications for the application. A test procedure tool is used to read the same feature selections, and create a test execution graph that describes the possible sequences in which the test specifications can be executed for an application derived from the SPL. Finally, a system test generator tool is used to generate a system tests document for the application that is used by the test engineer to define input data values and expected output values for the system tests, execute the system tests against the application, and verify whether the observed test results match the expected output values.
4 Validation CADeT was used to create functional models and customizable test specifications for two SPL case studies: a Banking System SPL, and an Automated Highway Toll System SPL. A set of applications to test was selected for each SPL, and then the decision tables and test specifications were customized for each application configuration of each SPL. The largest number of features in a feature interaction in any test specification in either case study was two. Table 2 shows that a 2- way combinatorial feature coverage criterion was applied to create 13 application configurations for the Banking System SPL and 16 for the AHTS SPL, compared with 864 and 224 possible application Table 2. Number of configurations and test specifications for each case study
#Features All combinations 2-way combinations #Use case scenarios #Test specifications No reuse Some reuse
Banking System SPL 12 864 13 21 23 299 127
AHTS SPL 16 224 8 28 30 149 52
Reusable Model-Based Testing
85
configurations, respectively. Table 2 shows that CADeT was applied to create 23 and 30 reusable test specifications for each case study. With no reuse, 299 and 149 test specifications would have been needed to cover the 13 and 8 application configurations. With copy and paste reuse (some reuse), this number would have been reduced to 127 and 52, considerably more test specifications than with CADeT. Thus, using CADeT created considerably less test specifications to cover all use case scenarios and 2-way feature combinations in each case study.
5 Conclusions This paper has described CADeT, a comprehensive model-based testing method for SPLs that combines feature-oriented and use case-based functional testing approaches for SPLs. Reusable test specifications are created from SPL models to cover all use case scenarios, and a set of application configurations are generated to cover selected feature combinations. Then, the test specifications of the SPL test suite are customized during featurebased test derivation for each application configuration. This method was evaluated on two case studies, and the results of each case study showed that the method could be used to substantially reduce the number of test specifications created for a SPL. Future research will investigate integrating different variability mechanisms with this approach, such as separation of concerns, and extending the approach to address integration testing of SPL architectures.
References 1. Gomaa, H.: Designing Software Product Lines with UML: From Use Cases to Patternbased Software Architectures. The Addison-Wesley Object Technology Series. AddisonWesley, Reading (2005) 2. Bertolino, A., Gnesi, S.: PLUTO: A Test Methodology for Product Families. In: Software Product-Family Engineering: 5th Int’l Workshop, Siena, Italy (2003) 3. Nebut, C., et al.: A Requirement-Based Approach to Test Product Families. In: Software Product-Family Engineering: 5th Int’l Workshop, Siena, Italy (2003) 4. Reuys, A., et al.: Model-Based Testing of Software Product Families. In: Pastor, Ó., Falcão e Cunha, J. (eds.) CAiSE 2005. LNCS, vol. 3520, pp. 519–534. Springer, Heidelberg (2005) 5. McGregor, J.D.: Testing a Software Product Line, SEI (2001) 6. Scheidemann, K.: Optimizing the Selection of Representative Configurations in Verification of Evolving Product Lines of Distributed Embedded Systems. In: 10th Int’l Software Product Line Conference. IEEE Computer Society Press, Baltimore (2006) 7. Gomaa, H., Olimpiew, E.: Managing Variability in Reusable Requirement Models for Software Product Lines. In: Proc. 10th International Conference on Software Reuse, Beijing, China (May 2008) 8. Kang, K.: Feature Oriented Domain Analysis. Software Engineering Institute, Pittsburg (1990) 9. Geppert, B., Li, J., Roessler, F., Weiss, D.M.: Towards Generating Acceptance Tests for Product Lines. In: 8th Int’l Conf. on Software Reuse, Madrid, Spain. Springer, Heidelberg (2004) 10. Cohen, D.M., et al.: The AETG System: An Approach To Testing Based on Combinatorial Design. IEEE Transactions on Software Engineering 23(7), 437–444 (1997)
A Case Study of Using Domain Engineering for the Conflation Algorithms Domain Okan Yilmaz and William B. Frakes Computer Science Department Virginia Tech {oyilmaz,wfrakes}@vt.edu
Abstract. In this study we used domain engineering as a method for gaining deeper formal understanding of a class of algorithms. Specifically, we analyzed 6 stemming algorithms from 4 different sub-domains of the conflation algorithms domain and developed formal domain models and generators based on these models. The application generator produces source code for not only affix removal but also successor variety, table lookup, and n-gram stemmers. The performance of the generated stemmers was compared with the stemmers developed manually in terms of stem similarity, source, and executable sizes, and development and execution times. Five of the stemmers generated by the application generator produced more than 99.9% identical stems with the manually developed stemmers. Some of the generated stemmers were as efficient as their manual equivalents and some were not. Keywords: Software reuse, domain analysis, conflation algorithms, stemmers, application generator.
1 Introduction In the early 1980s software companies started the systematic reuse process through domain engineering to improve software productivity and quality. There has been insufficient empirical study of the domain engineering process and domain products such as reusable components and generators. This paper addresses this problem by documenting and empirically evaluating a domain engineering project for the conflation algorithms domain. This domain is important for many types of systems such as information retrieval systems, search engines, and word processors. The application generator developed for this study extends the domain scope compared to previous ones. 1.1 Conflation Algorithms Domain Conflation algorithms are used in Information Retrieval (IR) systems for matching the morphological variants of terms for efficient indexing and faster retrieval operations. The conflation process can be done either manually or automatically. The automatic conflation operation is also called stemming. (Frakes W. B., 1992) categorizes stemming methods into four groups: affix removal, successor variety, n-gram and table lookup. Affix removal is the most intuitive and commonly used of these algorithm S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 86–94, 2009. © Springer-Verlag Berlin Heidelberg 2009
A Case Study of Using Domain Engineering for the Conflation Algorithms Domain
87
types. In order to determine the stem, affix removal algorithms remove suffixes and sometimes also prefixes of terms. Successor variety and n-gram methods analyze a word corpus to determine the stems of terms. Successor variety bases its analysis on the frequency of letter sequences in terms, while n-gram conflates terms into groups based on the ratio of common letter sequences, called n-grams. Table lookup based methods use tables which map terms to their stems. We did a domain analysis for the semantic automatic conflation algorithms domain. We analyzed 3 affix removal stemmers, a successor variety stemmer, an n-gram stemmer, and a table lookup stemmer. Based on this analysis, we created a generic architecture, developed reusable components, and designed and developed a little language and an application generator for this domain. We compared the performance of the automatically generated algorithms with their original versions and found that automatically generated versions of the algorithms produced nearly the same results as the original versions.
2 Related Work In this study, we used the DARE: Domain analysis and reuse environment (Frakes, Prieto-Diaz, & Fox, 1998). DARE draws on several DE research threads including faceted classification, feature modeling, automated IR, and artificial intelligence. The developers of DARE tried to use the best tools and methods available, including the domain engineering book metaphor. Since then, other tools and methods have been developed. These, along with earlier methods still in use, are surveyed in (Frakes & Kang, 2005). Using the DARE method, we performed domain engineering in two phases: domain analysis and domain implementation and collected all domain related information in a domain book. In information retrieval systems there is a need for finding related words to improve retrieval effectiveness. This is usually done by grouping words based on their stems. Stems are found by removing derivational and inflectional suffixes via stemming algorithms. The first affix removal stemming algorithm was developed by Lovins (Lovins, 1968). This algorithm did stemming by iteratively removing longest suffixes satisfying predefined suffix removal rules. Several other longest match affix removal algorithms have been developed since (Salton, 1996) (Dawson, 1974) (Porter, 1980) (Paice, 1990). The Porter algorithm is most commonly used because of its simplicity of implementation and compactness. Later Paice proposed another compact algorithm. Hafer and Weiss (Hafer & Weiss, 1974) took a different approach in their successor variety stemming algorithm and proposed a word segmentation algorithm which used successor and predecessor varieties to determine fragmentation points for suffixes. Successor and predecessor varieties are the numbers of unique letters after and before a substring in words in a corpus. Their algorithm applied several rules to identify the stem from the substrings of each word that appeared in a corpus. The successor variety algorithm has the advantage of not requiring affix removal rules that are based on the morphological structure of a language. However, the effectiveness of this algorithm depends on the corpus and on threshold values used in word segmentation. Adamson and Boreham (Adamson & Boreham, 1974) developed the N-gram algorithm that uses the number of distinct and common n-character
88
O. Yilmaz and W.B. Frakes
substrings to determine if two or more corpus words can be conflated. Similar to successor variety, the strength of this algorithm depends on the corpus and the cutoff similarity values chosen. More recently, Krovetz (Krovetz, 1993) developed the Kstem algorithm that does a dictionary lookup after applying affix removal rules to remove inflectional suffixes. (Frakes & Fox, 2003) analyzed four stemming algorithms in terms of their strength and similarities. They used the Hamming distance measure as well as other commonly used measures. (Fox & Fox, 2002) reported an application generator using finite state machines for longest match stemming algorithms. They generated computationally efficient stemmers for Porter, Paice, Lovins and S-removal stemming algorithms (Harman, 1991) and compared their performance with the developed versions of these algorithms. This paper extends the scope of analysis to other sub-domains of conflation algorithms by analyzing not only affix removal but also successor variety, n-gram, and dictionary lookup types of algorithms. For this paper we analyzed Lovins, Porter, and Paice as examples of longest match affix removal, and Successor Variety, N-gram, and K-stem as instances of the remaining three types of conflation algorithms. As the result of the domain analysis, we developed an application generator and generated stemmers for Porter, Paice, Lovins, successor variety, S-removal, and K-stem algorithms and compared Porter, Paice, Lovins, S-removal, and K-stem algorithms developed via this automated approach with the corresponding algorithms developed by humans.
3 Conflation Algorithms In order to develop a better domain model, we analyzed at least one example for each conflation algorithms subdomain. We analyzed ─ ─ ─ ─
Porter, Paice, Lovins as examples of Longest Match Affix Removal algorithms, K-Stem as an example of Table Lookup stemming algorithms, successor variety algorithm, and n-gram stemming algorithm.
4 DARE Domain Analysis Method In this study we used the DARE domain analysis method and organized the domain information of conflation algorithms in a DARE domain book. The major sections of the domain book were as follows: ─ Source information subsection contained documents related to the conflation algorithms domain: source code, system descriptions, system architectures, system feature tables, and source notes of the six conflation algorithms that we analyzed. Table 1 shows the system feature table of the conflation algorithms domain. ─ Domain scope subsection contained inputs, outputs, functional diagrams of conflation algorithms that were analyzed as well as a generic functional diagram that we developed as a result of domain analysis.
A Case Study of Using Domain Engineering for the Conflation Algorithms Domain
89
─ Vocabulary analysis subsection had basic vocabulary information, a facet table for the domain, a synonym table, a domain template, domain thesaurus document, and vocabulary notes. ─ Code analysis subsection showed source code analysis results for conflation algorithms that were analyzed. ─ Architecture analysis subsection contained a generic architecture diagram. ─ Reusable components subsection contained the components that were determined as reusable as the result of domain analysis. ─ Little language subsection contained a domain specific language represented in Backus-Naur form. ─ Application generator subsection contained application generator notes and the source code produced as a product of the conflation algorithms domain analysis. Table 1. System Feature Table of the Conflation Algorithms Algorithm Name Porter
Corpus Usage No
Dictionary Usage No
Natural Language English
Paice
No
No
English
Lovins
No
No
English
Successor Variety N-Gram K-Stem
Yes
No
Any
Yes No
No Yes
Any English
Type Longest Match Affix Removal Longest Match Affix Removal Longest Match Affix Removal Successor Variety N Gram Dictionary based Inflectional
Stem Generation Yes
Strength Medium
Yes
High
Yes
Medium
Yes
Low
No Yes
N/A Medium
One main goal of the DARE method is to develop a generic architecture that describes all systems in the domain. This architecture is formed after identifying commonalities and variabilities of these exemplar systems. The DARE method starts with scoping the domain that will be analyzed (Frakes, 2000). First the systems in the domain are described verbally. Then the verbal description is translated into a mathematical formalism, for example set and function notation. Once domain scoping is done, then domain exemplars are gathered and analyzed. After the scoping process, a functional diagram for each exemplar system is created, and then these diagrams are merged into a generic functional diagram which helps to identify sub-domains. Vocabulary analysis follows the domain scoping and creation of functional diagrams for domain exemplars. In the vocabulary analysis process, the domain documents and domain expert information are used to create an initial word set. From this set, via automatic and/or manual analysis a domain keyword set is
90
O. Yilmaz and W.B. Frakes
determined. These keywords are clustered into groups according to commonalities among them. From these word clusters a facet table is created for the domain. Each cluster is identified with a facet name and will become a facet category in the facet table. After that a domain template describing the domain verbally is created by using the facet categories. In the later stages of domain analysis and domain implementation the domain template and facet table are used to identify reusable components. In the architectural analysis the system architecture diagrams of each exemplar system are merged into a generic system architecture that can express variabilities as well as commonalities of all systems. Table 2. Reusable Components of Conflation Algorithms Domain
Reusable Component Category Hash Table operations Text file operations String manipulation operations String/character validation operations File processing/storage operation Word verification operations Suffix removal rules Suffix recode rules
Operations initialize, search and retrieve, add, delete, open, close, read line substring, string comparison, lowercase, uppercase, string length is AlphaNumeric, is Vowel, is Consonant, shorter than, longer than Read & store each word from in an input file (e.g. corpus, dictionary) check the size, check if it is alphanumeric, etc. remove a suffix if it is equal to a morpheme replace a suffix if it is equal to a morpheme
Table 3. Variable Components of Conflation Algorithms Domain
Algorithm Name N-Gram
Successor variety
K-Stem Paice Porter Lovins
Operations initialize, create, display n-grams for each word, determine common n-grams of two words, cluster words based on their common n-grams, merge or display clusters, add, remove words from clusters, etc create and analyze prefix hash table, calculate entropy, add, reset, display segments lookup command which checks the existence of a word in the dictionary hash iterate and intact commands isMeasure command recode and partial matching functions
A Case Study of Using Domain Engineering for the Conflation Algorithms Domain
91
Code analysis requires programming language knowledge and expertise. In this process the code of exemplar systems is analyzed in terms of common and different functionalities, and several software metrics such as those for complexity and maintainability. The goal of this process is to identify the reusable software components that can be used in domain implementation and to determine the important architectural elements. During domain implementation, reusable components are created, a little language is generated, and ultimately an application generator may be developed. Table 2 shows the reusable components that we determined by analyzing the generic architecture, the facet table and the domain template. We also summarized the variable components in Table 3. As another domain product, a programming language called a little language was developed specifically for the domain. Finally, an application generator was developed for the domain by implementing the reusable components and a code generator supporting the domain specific language.
5 Evaluation of Generated Stemmers We evaluated the application generator we developed by comparing the stemmers generated with the stemmers developed by humans in terms of the following characteristics of stemmers: • • • • •
Similarity of stems produced Time spent during development Size of the executable of the stemmer Number of lines of code (LOC) Total execution time
We also compared the box plots of elapsed stemming times of each word in the test set for each version of analyzed stemmers in Fig. 1. 5.1 Evaluation Method To evaluate the performance of stemmers we needed a test data set. We created a corpus containing 1.15 million words by combining about 500 articles from Harper's Magazine (Harpers Magazine), Washington Post Newspaper (Washington Post New Paper), and The New Yorker (New Yorker Magazine)with a sample corpus of spoken, professional American-English (Sample Corpus of Professional Spoken English). We generated a test file with 45007 unique words by using the text analysis functionality of the application generator. We evaluated, developed, and generated versions of Porter, Paice, Lovins, S-removal, and K-stem stemmers. All these algorithms were in the Perl programming language except for the developed version of the K-stem algorithm which was in C. While the code generated by the application generator was object oriented, the developed versions of these algorithms were not. During the evaluation process we verified the stems generated by these stemmers and fixed bugs in the developed code and in rule files for the application generator.
92
O. Yilmaz and W.B. Frakes Table 4. Comparison results for developed and generated stemmers
Alg. Name
Porter
Stem Similarity
Lovins
Paice
S-removal
Identical Different Identical Different Identical Different Identical 45006 1 45006 1 45007 0 45007 Devel. Generated Developed Generated Developed Generated DevelGenerated Time oped (hours) 4 12 3 NA 6 NA 0.5 Exec. Size Generated Developed Generated Developed Generated DevelGenerated (bytes) oped 849247 390778 900851 398528 874039 393640 839315 Number Generated Developed Generated Developed Generated DevelGenerated of oped LOC 453 126 1180 555 1069 1039 142 Exec. Time Generated Developed Generated Developed Generated DevelGenerated (seconds) oped 3.03 1.52 6.58 1.73 2.72 6.66 0.70
K-stem
Different Identical Different 0 44970 37 Developed Generated Developed 0.5 6 NA Developed Generated Developed 387443 856334 334689 Developed Generated Developed 36 719 2035 Developed Generated Developed 0.44
3.41
1.02
5.2 Evaluation Results Table 4 summarizes the evaluation results. All five stemmers generated by the application generator produced more than 99.9% identical stems with the developed stemmers. Preparing the rule file for the Porter algorithm took 4 hours while developing the same algorithms took 12 hours. Since the S-removal is a very simple stemming algorithm, both developing it and generating rule files for it took about half an hour. For the rest of the algorithms we report the rule file generation time since we did not have information about their actual development time. Executables generated from the Perl scripts of all generated stemmers were at least twice as big as the developed stemmers. Among all algorithms developed K-stem had the smallest executable. This was partly because it was developed in C rather than Perl. On the other hand, for the same reason developed K-stem had highest LOC among all stemmers. The generated stemmers were slower than the developed ones except for the Paice algorithm. We did not find a statistically significant difference between the generated and developed stemmers in terms of LOC and execution time due to the limited number of algorithms tested. 5.3 Analysis of Elapsed Stemming Times of Generated and Developed Stemmers Stemming times per word stemmed is reported in the box plot for each stemmer in Fig. 1. Developed K-Stem and Developed Paice had the lowest and highest average elapsed stemming times respectively. Generated stemmers for Paice and S-removal performed a little better than developed ones. On the other hand, developed Porter, Lovins, and K-stem performed much better than the generated versions of these algorithms. Although the total time spent by developed K-Stem was more than the developed and generated versions of S-removal stemmers, the average elapsed time for each word stemmed turned out to be much shorter. This was because the time spent during the dictionary reading was not included in the elapsed time for stemming each word. Fig. 1 shows many outliers for each stemmer. We stemmed the data set several times and compared the outliers in each case to determine the characteristics of these outliers. We saw that in each run we had different outliers and concluded that the
A Case Study of Using Domain Engineering for the Conflation Algorithms Domain
93
50 20 10 1
2
5
Elapsed Time (microsec)
100
200
500
outliers were not caused by the stemming algorithms or stemmers. Stemming operations were normally very fast operations taking less than 100 microseconds on the average. When the test was running, the other operations done by the windows operating system were affecting our result by causing outliers.
Dev. Porter
Gen. Porter
Dev. Paice
Gen. Paice
Dev. Lovins
Gen. Lovins
Dev. Sremoval Gen. Sremoval
Dev. Kstem
Gen. KStem
Stemmer Name
Fig. 1. Box Plot Diagrams for Elapsed Stemming Times of Stemmers in Log. Scale
6 Conclusion and Future Work In this paper we presented a case study of using domain analysis for the semantic conflation algorithms domain. We compared the performance of stemmers generated by the application generator with the corresponding stemmers developed by humans in terms of identical stem generation, development times, size of executables, number of LOC, and the total time spent to stem all terms in our test set. We created and used a corpus with 45007 words to test stemmers. Our results indicated that the stems produced by the generated and developed stemmers produced identical results for more than 99.9% of evaluations. We also determined that stemmers produced by application generators have bigger executables than the stemmers developed by humans. We did not find a statistically significant difference between the generated and developed stemmers in terms of LOC and the total time spent to stem all terms in the test set due to the limited number of algorithms tested. We also analyzed elapsed stemming times of these developed and generated stemmers. We presented a box plot diagram for each stemmer in terms of the elapsed stemming times. We determined that generated stemmers performed better for some cases and worse in some other cases on this measure.
94
O. Yilmaz and W.B. Frakes
In this study we have done a domain engineering project for affix removal, successor variety, n-gram, and table lookup types of stemming algorithms and generated code for all types other than the N-gram algorithm. In future work, we plan to generate a stemmer for N-gram as well. Also we did not compare the successor variety stemmer with a successor variety stemmer developed by humans, but hope to do this in the future.
References (n.d.) New Yorker Magazine (retrieved April 12, 2007), http://www.newyorker.com (n.d.) Sample Corpus of Professional Spoken English (retrieved April 12, 2007), http://www.athel.com/sample.html (n.d.) Harpers Magazine (retrieved April 12, 2007), http://www.harpers.com (n.d.) Washington Post New Paper (retrieved April 12, 2007), http://www.washingtonpost.com Adamson, G., Boreham, J.: The use of an association measure based on character structure to identify semantically related pairs of words and document titles. Information Storage and Retrieval, 253–260 (1974) Dawson, J.L.: Suffix removal and word conflation. ALLC Bulletin, 33–46 (1974) Fox, B., Fox, C.J.: Efficient Stemmer generation. Information Processing and Management: an International Journal, 547–558 (2002) Frakes, W.B.: Stemming Algorithms. In: Frakes, W.B.-Y. (ed.) Information Retrieval: Data Structures and Algorithms. Prentice-Hall, Englewood Cliffs (1992) Frakes, W.B., Fox, C.J.: Strength and similarity of affix removal stemming algorithms. SIGIR Forum, 26–30 (2003) Frakes, W.: A Method for Bounding Domains. In: IASTED International Conference Software Engineering and Applications 2000, Las Vegas, NV (2000) Frakes, W., Kang, K.: Software Reuse Research: Status and Future. IEEE Transactions on Software Engineering, 529–536 (2005) Frakes, W., Prieto-Diaz, R., Fox, C.J.: DARE: Domain analysis and reuse environment. Annals of Software Engineering, 125–141 (1998) Hafer, M., Weiss, S.: Word segmentation by letter successor varieties. Information Storage and Retrieval, 371–385 (1974) Harman, D.: How Effective is Suffixing? Journal of the American Society for Information Science, 7–15 (1991) Krovetz, R.: Viewing morphology as an inference process. In: 16th ACM SIGIR conference, Pittsburgh, PA, pp. 191–202 (1993) Lovins, J.B.: Development of a stemming algorithm. Mechanical Translation and Computational Linguistics, 22–31 (1968) Paice, C.D.: Another Stemmer. SIGIR Forum, 56–61 (1990) Porter, M.: An algorithm for suffix stripping. Program, 130–137 (1980) Salton, G.: Automatic information organization and retrieval. Mc Graw Hill, New York (1996)
Model Transformation Using Graph Transactions Leila Ribeiro, Luciana Foss, Bruno da Silva, and Daltro Nunes Universidade Federal do Rio Grande do Sul, Instituto de Inform´ atica, Av. Bento Gon¸calves, 9500, 91501-970, Porto Alegre - RS, Brazil
Abstract. Model transformations are central to model driven software engineering. The main aim of defining a model transformation is to reuse this model by adapting it to a new situation or context (aims of transformation include synthesis, reverse engineering, migration, optimization, refactoring, etc). Given two metamodels T 1 and T 2 a model transformation takes as input a model of T 1 and delivers as result a corresponding model with respect to T 2. Since many modelling languages are diagrammatic (like class-diagrams, message sequence charts, state charts), it is natural to use graphs as a formal basis to describe metamodels of these languages. Rules that transform graphs can be used to describe the transformation process. Here we propose the use graph grammars with transactions to describe model transformations. The notion of (graph) transaction can be very useful in proving essential properties of model transformation, like termination, confluence and correctness.
1
Introduction
Software systems are always evolving. Besides changes in the requirements a system has to satisfy, there may be other reasons for evolution, like the need for new architectural models for optimization or adaption to new platforms; the use of updated versions of data bases, maybe with different database schemas; adaption to new paradigms, like service-oriented architectures; use new languages, etc. One of the problems of software engineering is how to cope with such (sometimes drastic) changes, while assuring the quality of the software system. Quality is usually achieved by the use of solid software development and analysis techniques in all phases. These techniques require the existence of abstract descriptions of the system capturing different views, and also different levels of abstraction of a same view. They can be seen as models of the system under construction. Ideally, all models of a software system should be consistent. Only then one can guarantee, for example, that all analysis that was done at the specification level is valid for the generated code. But, how to cope with evolution in such a scenario? The direct inclusion of some new funcionality by just changing code artifacts may introduce design flaws and deviations from the specification compromising the quality of the system. However, it is also not feasible to reengineer the whole system.
This work was partially supported by CNPq.
S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 95–105, 2009. c Springer-Verlag Berlin Heidelberg 2009
96
L. Ribeiro et al.
One of the approaches to cope with evolution reusing software design and even code is Model Driven Software Engineering (MDE) [1]. The idea is that the modeling techniques used to construct a system should allow precise descriptions that are called metamodels. A model is thus an instance of the corresponding metamodel. Changes can be specified at metamodel level by rules that can be applied to all instances of these metamodels. These changes may be endogenous, or within the same metamodel, or exogenous, changing the metamodel description of the system [2]. They can be used to describe, for example, refinements or optimizations (endogenous) or synthesis or migration (exogenous). In any case, transformations allow the reuse of existing models, adapting them to new requirements, platforms, languages, levels of abstraction, etc. Model transformations may be simple (specifying just a small change) or very complex (specifying a change to a completely different kind of model or an involved refinement step). The transformation is usually described by a set of rules and, to assure that suitable outputs are obtained, the process should terminate and be confluent (no matter the order in which rules that govern the transformation are applied, the result is the same). One may also desire to analyze whether different transformations (for example, adding two different functionalities to a system) may interfere with each other. Moreover, it is also highly desirable that transformation is semantically correct: depending on the kind of transformation being performed, we may require that the semantics of the new model is equivalent, a conservative extension or related in some other way to the semantics of the original model. Since many specification languages are visual (like most UML diagrams), it is natural to consider that model transformations are based on rules that transform graphs. Indeed, there are lots of approaches that use graph transformation to model various kinds of transformation [3,4]. The basic idea is that the metamodel corresponding to a diagram can be described by a graph and, given metamodels M 1 and M 2, one can define rules to transform any instance of M 1 into an instance of M 2 as graph transformation rules. The area of graph grammars or graph transformations [5] offers a lot of results concerning various kinds of analysis (like termination, confluence, independence). A notion of transaction was proposed in [6,7], allowing to relate a sequence of steps to a more abstract step that describes the effect of the whole sequence. In this paper, we propose an extension of the notion of graph transactions to specify complex model transformations. In our approach, given a set of rules that specify a transformation, we can construct another set of rules that describes the abstract behavior of the transformation rules. These abstract rules can then be analyzed to check desired properties as well as to validate the transformation itself. In contrast to other approaches of using graph grammars to model transformation, our proposal is suitable for endogenous as well as for exogenous transformations. Moreover we do not need restriction operators to obtain the resulting model (as in [4]). This paper is organized as follows: Sect. 2 introduces the basic concepts of graph transformation to specify model transformation; Sect.3 shows how to use transactions for model transformation. Final remarks are presented in Sect. 4.
Model Transformation Using Graph Transactions
2 2.1
97
Graph Transformation for Model Transformation Using Graph Transformation to Describe Model Transformation
Many kinds of diagrams used to specify static as well as dynamic aspects of computational systems can be suitably represented as graphs. Metamodels describe a class of models, defining which diagrams can be seen as models of some type. To formalize this notion of metamodel, the notion of type graph can be used. A type graph defines types of vertices and edges that may appear in instance graphs. In this paper, we propose to enrich the definition of type graph by considering a structured type graph, in which one can distinguish the types of elements belonging to the different metamodels involved in the transformation. A model transformation is a description of how instances of one metamodel T 1 can be transformed into instances of another metamodel T 2. Any procedure to describe such transformation must deal with two metamodel descriptions (T 1 and T 2). Moreover, since the transformation is actually an algorithm, it may be necessary to use auxiliary data structures. In a graph transformation approach, all data types are described by graphs, and therefore these auxiliary structures will also be graph elements (vertices or edges). The basic idea is that transformation starts with a graph that is a model M 1 of type T 1. Then, while items of M 1 are are removed, items of type T 2 and/or auxiliary items may be generated. Finally, when all auxiliary items are removed and only items of type T 2 remain, the process is finished. Auxiliary items will be called unstable items. Depending on the kind of transformation being performed, there may be types that belong both to T 1 and T 2. The transformation process has 2 phases: Phase 1 (Local): During this phase, all items of type T 1 that should not belong to the resulting model will be treated. This means that they will be either (i) deleted or (ii) marked by some unstable arc that will be treated in phase 2. (i) is usually used for arcs, while (ii) is needed to treat deletion of vertices properly, because it is not possible to delete a vertex that is still being referenced to by some arc (we first have to deal with all references in a suitable way). In this phase, items of type T 2 as well as unstable items may be created, but it is only allowed to introduce unstable links between new elements and elements that are marked for deletion in the next phase. Phase 2 (Global): The aim of this phase is to treat all links to/from items marked for deletion, substituting them by links to appropriate items of type T 2. When all links were handled, items marked for deletion may be removed. According to these 2 phases, there are 2 kinds of unstable items: the ones that should be dealt with in phase 1, and the ones that are handled in phase 2. The former will be called unstable.1 and the latter, that correspond to deletion marks on vertices and links between old and new elements, will be called unstable.2. Figure 1 illustrates the proposed transformation process, where the first phase of the transformation creates elements of type T 2 and unstable items, generating
98
L. Ribeiro et al.
M1
T1
...
G1
T1+Unstable.1+Unstable.2+T2 Phase 1
Gi
...
Gn
Unstable.2+T2
M2
T2
Phase 2
Fig. 1. Graph Transformation Process
as a result a graph type over T 2 plus unstable.2 items, and the second phase handles all unstable.2 items, giving raise to the transformed model (completely typed over T 2). 2.2
Formal Definitions
A structured type graph will be the basis for the graph transformation. A graph is a set of vertices and a set of arcs plus two functions assigning source and target vertices to each arc. In order to relate two graphs we will use graph morphisms. A graph morphism is a mapping that associates all elements of the source graph to elements of a target graph, where the mapping of arcs must respect their source and target vertices. Definition 1 (graph and graph morphisms). A graph is a tuple G = VG , AG , sG , tG , where VG and AG are sets of vertices and arcs, and sG , tG : AG → VG are total functions, called source and target functions. A (total) graph morphism f : G → G is a pair of functions (fV : VG → VG , fA : AG → AG ) such that fV ◦ sG = sG ◦ fA and fV ◦ tG = tG ◦ fA . A type graph to transform from a metamodel T 1 to a metamodel T 2 is a structured graph T that contains both metamodels T1 and T2 plus auxiliary items that can be used in phases 1 and 2 of the transformation (TP 1 and TP 2 ). Definition 2 (MT-type graph). An MT-type graph T is a tuple TP 1 , TP 2 , T1 , T2 , such that there exist three incluT1 Qu QQ QQQ sions as depicted in diagram on the right, where T1 ( / TP 1 is the source metamodel, T2 is the target metamodel, 6 TP 2 m m m m m ) TP 2 includes the auxiliary items of phase 2. and TP 1 m T2 includes also the auxiliary items of phase 1. Given a fixed MT-type graph T , a T -typed graph GT is given by a graph G and T a graph morphism tG : G → TP 1 . A morphism of T -typed graphs f : GT → G is a graph morphism f : G → G that satisfies tG ◦ f = tG . A graph typed over an MT-graph T as defined above is actually a graph typed over TP 1 , and therefore it may contain elements of metamodels T 1 and T 2 plus unstable (.1 and .2) elements. In any phase of the transformation, elements of metamodels T 1 and T 2 will be considered as stable. Items of kind unstable.1 are unstable in phase 1 (they do not occur in phase 2). Unstable.2 elements will be considered stable in phase 1 and unstable in phase 2 (because these items are
Model Transformation Using Graph Transactions
99
not meant to be dealt with in phase 1). Given an MT-graph (a graph mapped to TP 1 ), it is always possible to get the corresponding projections to types T 1, T 2 and TP 2 by forgetting elements not typed with desired types (this is formally defined by a known universal construction called pullback). The behavior of a graph transformation system is determined by the application of graph rewriting rules [5]. A rule is composed by three graphs: the left-hand side L, the right-hand side R, and an interface K. This interface specifies the contact points in which the newly created items will be connected to the context (graph) in which the rule is being applied. A rule specifies that, once an occurrence of graph L is found in the current (graph) state, it can be replaced with graph R, preserving K. Therefore, items associated to K are preserved, those in L that are not in K are consumed and those in R that are not in K are created. An MT-rule is a special graph rule that cannot consume elements exclusively in T2 and neither create elements exclusively in T1 . We will only consider rules that consume something. A model graph transformation is defined as a set of MT-rules typed over an MT-type graph. Definition 3 (rules and model graph transformation - MGT). A T lq
rq
typed MT-rule is a tuple q : Lq ← Kq Rq , where q is the name of the rule, lq is a strict inclusion, rq is an injective morphism and Lq , Kq and Rq are T -typed graphs, such that ∀a ∈ Lq (tLq (a) ∈ (T2 − T1 ) → a ∈ rng(lq )) and ∀b ∈ Rq (tRq (b) ∈ (T1 − T2 ) → b ∈ rng(rq )). A model graph transformation is a tuple M = T, P , where T is an MT-type graph, P is a set of T -typed graph rules. The application of a rule is given by a direct derivation, which deletes all items that shall be consumed and includes all items that shall be created. A direct derivation exists only if for all deleted vertices, there are not arcs pointing to/from them. A derivation is a (possibly infinite) sequence of direct derivap1 ,m1 p2 ,m2 tions, denoted by GT0 ⇒ GT1 ⇒ GT2 · · · , where each rule pi is applied to Gi−1 , using the occurrence mi and resulting in Gi . If i ≤ n, i. e., the derivation is finite, we denote by GT0 and GTn its initial and final graphs, respectively. 2.3
Example
In Figure 2 we show an example of model transformation. This transformation takes a partial entity-relationship class diagram (left-side of Figure 2) and generates a detailed design (right-side). Due to space limitations we illustrate the transformation for only one entity (Paper). The transformation applies two wellknown design patterns in the JavaEE Community - DAO (Data Access Object) and DTO (Data Transfer Object) [8]. For each class stereotyped as Entity in the source model, a DAO interface and a DAO implementation classes with default methods are generated. Moreover, a DTO class is created, including the Entity attributes, gets/sets accessors and keeping other existing methods. The motivation to use these design patterns in a detailed design class diagram depends on design decisions, such as implementation platform, persistence mechanism and so on.
100
L. Ribeiro et al. <> PaperDAO
paperId: Integer title: String version: String publisher: Publisher authors: Collection
+ createPaper(paperDTO: PaperDTO): Boolean + deletePaper(paperID: Integer): Boolean + findPaper(paperID: Integer): PaperDTO + updatePaper(paperDTO: PaperDTO): Boolean
<<Entity>> Paper paperId: Integer title: String version: String publisher: Publisher authors: Collection
<> PaperDTO
Model Transformation
+ getPaperInfo(): String + setPaperID(id: Integer): void + getPaperID(): Integer + setTitle(title: String): void + getTitle(): String + setVersion(version: String): void + getVersion(): String + setPublisher(publisher: PublisherDTO): void + getPublisher(): PublisherDTO + setAuthors(authors: Collection): void + getAuthors(): Collection
<> PaperDAOImpl
+ getPaperInfo(): String
+ createPaper(paperDTO: PaperDTO): Boolean + deletePaper(paperID: Integer): Boolean + findPaper(paperID: Integer): PaperDTO + updatePaper(paperDTO: PaperDTO): Boolean
Fig. 2. A model transformation example
The explanation of those two design patterns used in the example goes beyond the scope of this paper. The illustrated situation is an example of an endogenous and vertical software transformation, taking a source model in UML (class diagram) and generating a target model, which is also a UML class diagram. It can be viewed as a PIM (Platform Independent Model) to PSM (Platform Specific Model) transformation in the MDA (Model-Driven Architecture) context [9]. The structured type graph for this example is shown in Figure 3. Metamodel T 1 has classes that may be stereotyped with Entity. In the transformed model, we will have 3 new kinds of stereotypes: DTO, Interface and DAO. Since we are describing an endogenous transformation, the basic modelling mechanism (class diagram) remains the same (shared by T 1 and T 2). Unstable items are dashed (the only stable items that are dashed are the relations Rea and Dep), and identified with .1 or .2 depending on which phase they should be treated. These items do not belong neither to T 1 nor to T 2. We adopt a graphical notation with special shapes for vertices and arcs and sometimes do not draw vertices and arcs explicitly (this the case for vertex Stereotype, written inside the square representing Class vertices in the rules). The rules that govern the transformation are depicted in Figures 4 and 5 (Phase 1) and Figure 6 (Phase 2). Rules in Figures 5 and 6 are generic (may be used with any T 1-model), but the rule in Figure 4 is specific to this model. In our example, we have one class with stereotype Entity, and therefore we have one start rule. This is the first rule to be applied in the transformation, and it
T1
<<Entity>> Meth result
par Dep
tar attr
Class
T2
<> <> <>
tar.1 attr.1
Rea id
L.1 Old.2 attr.2 result.2
String
id.1
Class.1 DAO.1 DTO.1 Imp.1
NotEnt.2
Fig. 3. MT-Type Graph
TP1 = T1+T2+Unstable.1+Unstable.2 TP2 = T1+T2+Unstable.2
Model Transformation Using Graph Transactions Paper
Paper
<<Entity>>
tar
Paper
getPaperInfo
id.1
title
Integer
version
String
result.2
Old.2
startPaper paperID.1
paperID
getPaperInfo
DAO.1 Paper.1 DTO.1
Paper
result
tar.1
Imp.1
<<Entity>>
id
id
stype
101
publisher
authors
Publisher
Collection
version.1
title.1
String
Integer
publisher.1
Publisher
authors.1
Collection
NotEnt.2
Fig. 4. Start Rule – Phase 1
DTO.1
genDTO
E.1
DAO.1
E.1
<>
E.1
E.1
E
genDAO
E genAttr
attr.1
<>
<>
E
E
<>
E
E’ <>
E
tar.1
genTarget
result.2
Imp.1
genInter
Integer
<>
E
Integer
result
E
E L.1
deleteE updateE
<>
E
<>
E
result findE
removeTempEnt
E.1 <>
<
tar
Meth
E
findE
result createE
E.1 E.1
getatr
E.1
Meth <>
E
deleteE updateE
result
result
E.1
<>
createE
attr.2
setatr
E’
result
result
Integer
E.1
<>
E.1
result
Integer
<>
<>
E
E
link <>
E
removeStereoType
<<Entity>>
<>
E
L.1
Fig. 5. Rules – Phase 1
generates an unstable class vertex containing all attributes and methods of the class to be transformed. Moreover, it generates an Old.2 mark in the original class, marking it for deletion. The rules also mark all classes that are not of stereotype Entity by connecting them via unstable arcs to new unstable node (called NotEnt.2). We have to insert as many of these edges as the degree of each class vertex (each will be used to handle one of the references to this vertex). Other rules of phase 1 are shown in Figure 5. These rules create the new classes with new stereotypes, move all attributes and methods of original classes
E’
E’
E’
attr.2
redirectAttrDTO attr
<>
E’
E’
Meth
E
E
<>
<>
E
redirectAttrNE
E’
attr
<>
E’
E
removeNotEnt
E’
result.2
Meth
redirectParNE
Old.2
id
E’
result
NotEnt.2
NotEnt.2
E NotEnt.2
Meth result
<>
E’
NotEnt.2
NotEnt.2
redirectParDTO
<>
E’
attr.2
E’
result.2
<>
<>
E
Fig. 6. Rules – Phase 2
removeEntity
E
Meth
102
L. Ribeiro et al.
to these new classes, create the required relationship between these new classes, and finish by removing the unstable entity node and the stereotype Entity (these rules can only be applied if there is no arc referencing these vertices). Then we proceed to Phase 2, depicted in Figure 6: all links connected to old classes are moved to new classes and the process finished by removing all old classes.
3
Graph Transactions
The notion of graph transaction was introduced in [7] to describe derivations that accomplish some task. Here, we extend this concept to handle MT-graphs, and thus transactions will characterize complete model transformations. A transaction always starts in states with elements of type T1 and finishes in states with elements of TP2 (condition 1 in the next definition). During the execution of a transaction, no stable state is reached (except the final state), that is, a transaction can not be split into other transactions (condition 2). The start state of a transaction contains exactly what is needed to accomplish the transaction (condition 3) and all elements of the target metamodel (T 2), once created, can not be consumed within the transaction (condition 4). MT-transactions are transactions of phase 2, reaching a state in which all elements are of type T 2. q1 ,m1
Definition 4 (transaction). A transaction is a derivation ρ = G0 ⇒ . . . qn ,mn ⇒ Gn which satisfies the following properties: (1) G0 is typed over T1 and Gn is typed over TP2 ; (2) any intermediate graph Gi (i = 0, n) is not stable (with respect to TP 2 ); (3) for all a ∈ G0 , there is x ∈ Lqi , such that mi (x) = a; and (4) for each derivation step δ (in ρ), if a ∈ Gi is created by δ, such that tGi (a) ∈ T2 , then there is no derivation step in ρ consuming a. If all items in Gn are typed over T2 , ρ is an MT-transaction. An mgt can be seen at three levels of abstraction. It can be viewed as a model transformation where both stable and unstable items of states are visible, but we can also abstract away from the unstable.1 states and observe only complete transactions of phase 1. Formally, this gives rise to another mgt, where the rules correspond all transactions of the original mgt. Analogously, we can obtain complete transactions of phase 2. This definition requires the notion of the rule induced by a derivation sequence, a known construction in the literature [5]. which basically builds a rule using the initial and final graphs of the derivation. Considering an mgt M, we can build an abstract mgt A(M): the type graph is the stable type graph of M, that is, TP 2 ; the set of rules contain all abstract rules corresponding to transactions of M. In A(M) we have the abstract mgt associated to the first phase of transformation model, because we forgot all unstable.1 elements and can execute each transaction of M in only one step. By taking A(A(M)), we have the abstract mgt associated to the second phase of transformation, because we forgot unstable.1 and unstable.2 elements and can execute each MT-transaction of A(M) in only one step.
Model Transformation Using Graph Transactions
103
Definition 5 (Abstract MGT). Let M = TP1 , TP2 , T1 , T2 , P be an mgt. The abstract mgt associated to M, denoted by A(M), is the mgt TP2 , TA , T1 , T2 , P , where P is the set of abstract rules corresponding to transactions ρ of M and TA is the graph T1 ∪ T2 . We denote by A1 (M) = A(M) and A2 (M) = A(A(M)), the abstract mgts associated, respectively, to the first and second transformation phases of M. Transactions of phase 1 describe local transformations of each class, without considering interconnections between classes. Transactions of phase 2 (or MTtransactions) show the global view of the transformation process. In our example, there is one transaction performing the local transformation of class Paper, leaving all references to other classes to be solved in the next phase. This transaction is given by the application of rules startPaper, genDTO, genAttr (5 times), genTarget, genDAO, genInter and removeTempEnt. The abstract rule associated to the MT-transaction (phase 2) is the one shown in Figure 2. Main theoretical results concerning transactions that can be adapted to model graph transformations. An abstract rule represents in a concise way essentially the same transformation of the corresponding sequence of (concrete) rules. Indeed, the abstract system of an mgt has the same transactions of the concrete mgt, i.e., their behaviors are the same when we forget the auxiliary (unstable) elements. This fact was proved in [7] by means of the construction of an adjunction between the two views (abstract and concrete) of the system. The proof has been carried out for graph transformation systems with simple type graphs. These results can be lifted to model graph transformations, allowing the use of abstract rules as basis for analysis of model transformations (instead of using all concrete ones). This is possible due to the restrictions imposed on MT-type graphs. These restrictions allow also to use the procedure defined in [6] to construct all transactions of a graph transformation system, obtaining automatically the abstract system of a model transformation. Now we discuss how transactions can be used to aid analysis of model transformations. Termination: The transformation process finishes when there is no graph rule that can be applied and the current state is typed over T2 . By finding the abstract rules that represent the transformation, we can be sure that it is possible that the process terminates. To guarantee that this always happens, we have to perform proofs by induction based on the initial model and the rules that describe the transformation using, for example, approaches like [10] and the AGG tool [11]. Confluence: A model transformation is confluent if, for each source model, the processes of transformation results in a unique target model. For graph transformations, confluence is well studied [5]. In the proposed approach, proving confluence reduces to the proof of existence of only one rule at the abstract system of the second phase, i.e., that the mgt has only one MT-transaction. Semantical Correctness: A model transformation can be considered correct if it preserves the semantics of the system in the desired way. An approach to prove semantical correctness of model transformations by using graph transformation
104
L. Ribeiro et al.
rules to define the operational behavior of visual models was presented in [12]. In [13] a formal definition of compositionality for mappings from typed graphs to semantic domains was proposed. Besides, several works have investigated behavior preservation of model refactoring using graph transformations, such as [3], [14]. These approaches deal with very simple transformations, which can be defined by only one rule, or provide ad hoc methods to obtain the abstract rule that corresponds to a whole transformation. For complex transformations, it is usually not true that each rule preserves semantics, since the target model is completed only at the end of a series of rule applications. By generating the abstract rules corresponding to a model transformation, we provide a formal basis for the use of existing approaches in the context of complex transformations.
4
Conclusion
The main aim of this paper is to present an approach to enable reuse of models via formally defined transformations. We provide a framework in which complex transformations may be described in a well-founded way, by characterising explicitly elements that are needed as auxiliary items during the transformation process, and proposing two phases to deal with different aspects of the transformation process (local vs. global transformation). Abstract rules associated to transactions cab be used as basis for analysis. Due to space limitations, it was not possible to illustrate the proposed concepts with a larger example, nor show the results formally, we rather focused on presenting the main ideas and potential of the proposed approach. As future work, we plan to extend this approach to attributed graphs, as well as use negative application conditions [5]. We also intend to extend existing tools to implement automatic generation and analysis based on transactions.
References 1. Schmidt, D.C.: Model-driven engineering. IEEE Computer 39(2), 25–31 (2006) 2. Mens, T., Gorp, P.V.: A taxonomy of model transformation. ENTCS, vol. 152, pp. 125–142 (2006) 3. Mens, T., Demeyer, S., Janssens, D.: Formalising behaviour preserving program transformations. In: Corradini, A., Ehrig, H., Kreowski, H.-J., Rozenberg, G. (eds.) ICGT 2002. LNCS, vol. 2505, pp. 286–301. Springer, Heidelberg (2002) 4. Ehrig, H., Ehrig, K.: Overview of formal concepts for model transformations based on typed attributed graph transformation. ENTCS, vol. 152, pp. 3–22 (2006) 5. Rozenberg, G.: Handbook of Graph Grammars and Computing by Graph Transformation, Fondations, vol. 1. World Scientific, Singapore (1997) 6. Foss, L.: Transactional Graph Transformation Systems. Phd thesis, Federal University of Rio Grande do Sul, Porto Alegre, Brazil (2008) 7. Baldan, P., Corradini, A., Foss, L., Gadducci, F.: Graph transactions as processes. In: Corradini, A., Ehrig, H., Montanari, U., Ribeiro, L., Rozenberg, G. (eds.) ICGT 2006. LNCS, vol. 4178, pp. 199–214. Springer, Heidelberg (2006)
Model Transformation Using Graph Transactions
105
8. Alur, D., et al.: Core J2EE Patterns: Best Practices and Design Strategies. Core Design Series. Sun Microsystems, Inc (2003) 9. OMG: Mda guide version 1.01 (2003) 10. Costa, S.A., Ribeiro, L.: Formal verification of graph grammars using mathematical induction. In: Brazilian Symposium on Formal Methods, pp. 161–176 (2008) 11. Taentzer, G.: AGG: A graph transformation environment for modeling and validation of software. In: Pfaltz, J.L., Nagl, M., B¨ ohlen, B. (eds.) AGTIVE 2003. LNCS, vol. 3062, pp. 446–453. Springer, Heidelberg (2004) 12. Ehrig, H., Ermel, C.: Semantical correctness and completeness of model transformations using graph and rule transformation. In: 4th Int. Conference on Graph Transformations, pp. 194–210. Springer, Heidelberg (2008) 13. Bisztray, D., Heckel, R., Ehrig, H.: Compositionality of model transformations. ENTCS, vol. 236, pp. 5–19 (2009) 14. Rangel, G., Lambers, L., Knig, B., Ehrig, H., Baldan, P.: Behavior preservation in model refactoring using dpo transformations with borrowed contexts. In: Ehrig, H., Heckel, R., Rozenberg, G., Taentzer, G. (eds.) ICGT 2008. LNCS, vol. 5214, pp. 242–256. Springer, Heidelberg (2008)
Refactoring Feature Modules Martin Kuhlemann1 , Don Batory2, and Sven Apel3 1 University of Magdeburg, Germany [email protected] 2 University of Texas at Austin, USA [email protected] 3 University of Passau, Germany [email protected]
Abstract. In feature-oriented programming, a feature is an increment in program functionality and is implemented by a feature module. Programs are generated by composing feature modules. A generated program may be used by other client programs but occasionally must be transformed to match a particular legacy interface before it can be used. We call the mismatch of the interface of a generated program and a client-desired interface an incompatibility. We introduce the notion of refactoring feature modules (RFMs) that extend feature modules with refactorings. We explain how RFMs reduce incompatibilities and facilitate reuse, and report our experiences on five case studies.
1
Introduction
In feature-oriented programming, a feature is an increment in program functionality and is implemented by a feature module [1]. Feature modules can add new classes to a program, add new members, and extend members of existing classes. It is common for a program composed from feature modules to be used by another program [2], which we call an environment . An environment expects a composed program to have names of classes or methods that can be different from what was generated. We call the non-matching of expectations an incompatibility between the composed program and its environment. Incompatibilities occur frequently and hinder reuse [9,20,14]. In this paper, we concentrate on refactorings to eliminate incompatibilities. A refactoring alters the structure of a program but not its behavior [22,6]. Existing approaches can be used to integrate a program – also with refactorings – but they have problems: To adapt a program composed from feature modules using contemporary refactoring engines like Eclipse [7], the program has to be composed first and then refactorings are applied to it. The key problem is, if there are n optional features in producing a program and m optional refactorings, then
Martin Kuhlemann was supported and partially funded by the DAAD Doktorandenstipendium (No. D/07/45661). Batory’s work was supported by NSF’s Science of Design Project #CCF-0724979. Sven Apel’s work was supported in part by the German Research Foundation (DFG), project number AP 206/2-1.
S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 106–115, 2009. c Springer-Verlag Berlin Heidelberg 2009
Refactoring Feature Modules
107
2n+m program variants are possible. Hence, brute force is not an option [10]. Wrappers (a.k.a. adapters), as a second approach, increase program complexity as they introduce additional methods and classes [9], and meta-programs require developers to guarantee the resulting program can be compiled. We later discuss these approaches and others in detail. In contrast to prior work, we aim at a unification of features and refactorings in order to establish a general model of configurable and reusable software based on transformations. We propose that object-oriented refactorings be included in feature modules, Feature Module Base called refactoring feature modules (RFMs). public class Container { 1 List elements; 2 We illustrate how RFMs automate recurvoid insert front(Element e){ 3 ring tasks that eliminate incompatibilities. elements.add(e); 4 } 5 When an off-the-shelf program is moved } 6 into a feature module then RFMs help automate its integration with other programs. Feature Module LimitedSize We demonstrate the practicality of our refines class Container { 7 int depth; 8 approach with five case studies.
2
Background
void setElements(List newElems){ elements=newElems; } void insert front(Element e){ Super.insert front(e); depth= elements.size(); }
9 10 11 12 13 14 15 16
Feature-Oriented Design. In Figure 1, } we show three feature modules implemented in Jak, a superset of Java that Feature Module ContainerAsDeque supports feature modularity and feature public class Deque { 17 Container c; 18 composition [1]. When feature modules are void add front(Element e){ 19 selected in a configuration process they add c.insert front(e); 20 } 21 classes or class refinements to a given provoid setElements(List newElems){ 22 gram. A class refinement , which is indic.setElements(newElems); 23 } 24 cated by the keyword refines, adds members } 25 to and extends methods of existing classes. Feature module Base defines class Container. Module LimitedSize refines class Fig. 1. Feature-oriented design of a Container by adding field depth and container library method setElements. Existing methods are extended by overriding, e.g., method insert front (Lines 12-15) refines method insert front of class Container (Lines 3-5) via an inheritance-like mechanism. This method refinement adds statements and calls the refined method using Jak’s keyword Super (Line 13). Feature module ContainerAsDeque adds a new class Deque. The result of composing Base, LimitedSize, and ContainerAsDeque includes both classes Container and Deque. In this example, Deque is a wrapper class (a.k.a. adapter class) for Container, i.e., by delegating methods it makes Container objects accessible under the name Deque and makes method insert front of Container accessible under the name add front of Deque.
108
M. Kuhlemann, D. Batory, and S. Apel
Container _elements _depth insert_front() setElements()
(a)
ContainerToDeque refactoring
Deque _elements _depth insert_front() setElements()
InsertToAdd refactoring
(b)
Deque _elements _depth add_front() setElements()
(c)
Fig. 2. Refactoring Container with ’Rename Class’ and ’Rename Method’
Refactoring. A refactoring is a transformation that alters the structure of a program without altering its observable behavior [22,6]. One of the uses of refactorings is to remove incompatibilities among programs in order to increase reuse [22]. Two common refactorings are ’Rename Method’ and ’Rename Class’.1 We use them as examples throughout the paper. In Figure 2a, we depict class Container that has been composed from the feature modules Base and LimitedSize of Figure 1. Figure 2b shows the result of performing the refactoring ContainerToDeque. ContainerToDeque renames class Container into Deque and adjusts all references. Figure 2c shows the resulting class after the refactoring InsertToAdd. InsertToAdd renames method insert front into add front and adjusts all calls. Refactorings have parameters that define the target program elements [19]. For example, the parameters of a ’Rename Method’ refactoring are (1) the qualified name of the method to rename and (2) the new method name. We use the term refactoring type for the template that expects parameters. For example, ’Rename Class’ and ’Rename Method’ are refactoring types. Once its parameters are provided, the refactoring is fully specified and can be applied. Fully specified refactorings can have names, e.g. the ’Rename Class’ refactoring that renames Container to Deque is called ContainerToDeque (see Fig. 2).
3
Refactoring Feature Modules (RFMs)
A refactoring feature module (RFM) integrates refactorings with feature modules. The basic idea is to define refactorings in refactoring units that become elements of feature modules. By packaging one refactoring per feature module, a particular sequence of refactorings can be applied to a program, just like feature module sequences are composed to build programs. That is, program generation and restructuring are integrated with RFMs. Concept. Every refactoring type has an interface, which contains a getter method for each parameter of the refactoring type. A refactoring unit is a classlike module that implements a refactoring interface. It implements each getter method by returning the value for a designated parameter. Together the parameter values of a refactoring unit fully specify a particular refactoring. We 1
’Rename Method’ changes the name of a method and ’Rename Class’ changes the name of a class [6].
Refactoring Feature Modules
109
choose to represent refactorings as class-like modules because this is similar to feature-oriented refinements, and technically it allows us to reuse tool support. Figure 3 depicts a sample RFM, called ContainerToDeque, which encapsulates a Feature Module ContainerToDeque refactoring unit MyRenameClass. MyRenameClass defines a ’Rename Class’ refac- refactoring MyRenameClass implements 1 RenameClassRefactoring { toring, i.e., it implements the interface String getOldClassId(){return ”Container”;} 2 RenameClassRefactoring and defines the String getNewClassName(){return ”Deque”;} 3 4 getter methods getOldClassId and get- } NewClassName. The getters of MyRenameClass return the qualified name of Fig. 3. Refactoring unit that renames the class to rename and the new class Container into Deque name. Refactorings of other types than ’Rename Class’ are defined analogously. In Figure 4, we show a design in which RFMs Base are applied successively (in top-down order) to Container the composition of the two feature modules _elements Base and LimitedSize. InsertToAdd is composed insert_front() after ContainerToDeque and renames method LimitedSize Deque.insert front into add front. When all modules Container are selected in a configuration process the result is _depth the same as composing the feature modules of Figinsert_front() ure 1 (class Container is accessible under the name setElements() Deque; method Container.insert front is accessible ContainerToDeque under the name add front of class Deque). <> Control the scope of RFMs. A transformation MyRenameClass is applied when an RFM is composed [1]. That is, getOldClassId() the program that is synthesized by composing modgetNewClassName() ules prior to an RFM is transformed by that RFM. InsertToAdd In Figure 4, the classes refactored by the RFMs <> ContainerToDeque and InsertToAdd are limited to MyRenameMethod classes created by feature modules these RFMs folgetOldMethodId() low. That is, ContainerToDeque refactors the code getNewMethodName() added by the feature modules Base and LimitedFig. 4. Sequence of RFMs Size but not code added/changed by InsertToAdd as InsertToAdd is composed after ContainerToDeque. If an additional feature module NewContainer would apply after ContainerToDeque and introduce a second class Container, like feature module Base, this class would not be affected by ContainerToDeque because it would be added after ContainerToDeque. With RFMs, program elements can be both added and deleted (e.g., renaming can be represented as a sequence of deleting and creating code elements). After an RFM renames a method, the old method no longer exists. If a subsequent feature module or RFM references the renamed method by its old name, an error is reported. To guarantee the absence of such errors in all feature compositions is possible with techniques of safe composition [12], another topic that we are investigating.
110
M. Kuhlemann, D. Batory, and S. Apel
Deque
from Fig. 1 without RFMs
Container _elements _depth insert_front() setElements()
add_front() setElements()
Deque _elements _depth add_front() setElements()
(a)
from Fig. 4 with RFMs
(b)
Fig. 5. Composition results
RFMs in Action. In the introduction, we observed that generated programs often do not have the correct structure for them to be reused as-is in an environment (e.g., legacy code) [9]. Here is where RFMs can eliminate incompatibilities and promote reuse without altering the functionality of the generated program. RFMs allow us to avoid forwarding methods and classes (commonly used for integration), and thus simplify the resultant program. Figure 5 shows, the composed program in Figure 5b only encapsulates a class with the desired name Deque and no obsolete class Container as in Figure 5a. Tool Support. We have implemented RFMs as an extension to the Jak language, which adds support for feature modules to Java [1]. We use the AHEAD tool suite [1] to compose feature modules. We extended AHEAD with a plugin mechanism that encapsulates a template program of one refactoring type, e.g., the ’Rename Method’ refactoring type is implemented in its own plugin. Refactoring units refer to a plugin with their interface declaration and parameterize the refactoring template program with their getters. More details are given in a technical report [11].
4
Case Studies
We report on experiences with RFMs using two larger and three smaller case studies. We (1) transformed an off-the-shelf library in order to be able to reuse it in an incompatible database engine; (2) integrated variants of configurable libraries using RFMs with a legacy environment; (3) used uncommon refactorings to integrate a library of graph data types (GDTs); (4) integrated a large Eclipse library using RFMs with minimal effort, and (5) integrated a library of abstract data types (ADTs) and thereby removed wrapper classes and methods that became obsolete with RFMs. In Table 1, we show the transformed programs and the refactorings applied to them. Logging libraries. The off-the-shelf logging library Log4J2 cannot be used as-is by the database SmallSQL3 (∼20K lines of source code) due to incompatibilities. To standardize logging in SmallSQL we applied three RFMs to restructure Log4J such that it can be used in SmallSQL. One RFM moves class org.apache.log4j.Logger into the SmallSQL package smallsql.database and two RFMs rename 2 3
http://logging.apache.org/log4j/ http://www.smallsql.de/
Refactoring Feature Modules
111
Table 1. Information on case studies Program Log4J ZipMe Raroscope TrueZip GDT Workbench.texteditor ADT library
#SLOC* Refactorings ∼12K ∼3K ∼250 ∼13K ∼1K
1x Move Class, 2x Rename Method 2x Move Class, 1x Rename Class 2x Move Class, 2x Rename Class 2x Move Class, 2x Rename Class, 1x Rename Method 4x Move Class, 2x Rename Class, 2x Rename Method, 6x Encapsulate Field, 2x Extract Interface ∼16K 1x Rename Class, 2x Rename Field 59 1x Rename Class, 1x Rename Method *lines of source code
methods into SmallSQL-compatible names. The RFMs transform single code elements and a number of references to these elements automatically. For example, to make class Logger compatible, we did not have to know and enumerate those 144 points in 38 Log4J classes (distributed over 10 packages), that reference the moved class and must be transformed; we also did not have to find the numerous members that needed to be qualified as public when we moved the class – the ’Move Class’ RFM performs these transformations automatically. We observed that one incompatibility could not be eliminated by refactoring Log4J. We introduced with a feature-oriented refinement a single default constructor into the Logger class that calls setters. This way, RFMs do not replace refinements but complement them to integrate programs. As a result, we can now select either the informal SmallSQL logging engine or the Log4J standard logging library for the SmallSQL database in a configuration process. RFMs allow Log4J (and future releases of it) to be reused in the formerly incompatible SmallSQL environment. We defined the adaptation changes once. We found the effort to define RFMs is small and found it comfortable that the code changes the selected RFMs must perform are applied automatically (hidden from us). Configurable compression libraries. ZipMe4 is a library to access ZIP archives, Raroscope5 is a library to access RAR archives, and TrueZip6 can access TAR archives. The used versions of ZipMe and Raroscope are configurable, i.e., different library variants can be composed for each of them from selectable features like Checksum. Furthermore, we developed a graphical tool that used an old library to analyze files inside ZIP archives (file names, last modification date, uncompressed footprint) and decompress them. We wanted to replace the old library with ZipMe, Raroscope, and TrueZip to also analyze RAR and TAR archives with our tool. But all variants of these libraries were incompatible with our tool. We applied a number of RFMs to automatically restructure variants of 4 5 6
http://sourceforge.net/projects/zipme/ http://code.google.com/p/raroscope/ https://truezip.dev.java.net
112
M. Kuhlemann, D. Batory, and S. Apel
the libraries such that they can be reused in our tool (e.g., in ZipMe we renamed class ZipArchive into ZipFile). We observed that some incompatibilities cannot be eliminated by refactoring the library variants. This was the case for creating archive representations – our tool passes a File argument but all variants of the libraries take a FileInputStream or String argument. We added a feature module with a single factory method to each library and call the methods in order to bridge this gap. For TrueZip the feature module also encapsulates a method to access streams of single archive entries with certain parameters. Raroscope provides no such streams, so we disabled decompression here (still we can analyze archives). Again, RFMs do not replace refinements but complement them to integrate programs. Technically, the version of ZipMe can be composed from 13 features to 26 different variants. The version of Raroscope can be composed from 5 features to 24 different variants. We composed different variants of the configurable ZipMe and Raroscope libraries and all were compatible with our tool automatically when we selected the refactoring features.7 Interestingly, the variants were compatible although only the fully-fletched versions had been composed before. After we applied RFMs to TrueZip, its implementation became compatible with our tool. We now also can analyze and decompress TAR archives with our tool. Beside of renaming and moving the TrueZip representations of archives and archive entries, we had to rename the archive method getArchiveEntries into entries because our tool expects this name. For TrueZip, RFMs automate adaptation changes when new versions of TrueZip are released. Graph library. We integrated a configurable library of GDTs [17] (15 features, 55 library variants) with RFMs into an incompatible environment that used originally the graph library OpenJGraph8 . Beside renaming and moving Graph and Vertex classes, we had to encapsulate 6 fields in these classes with access methods using RFMs and had to extract interfaces for these classes. With refinements we added five methods. With RFMs, we can now configure multiple GDT variants to be compatible with the OpenJGraph client. Eclipse library. Dig et al. reported on incompatible environments of the Eclipse library ’workbench.texteditor’ (16K lines of source code) [5]. We applied three RFMs to automatically restructure ’workbench.texteditor’ such that it can be reused in these environments. One RFM renames class Levenshtein into Levenstein because this name was expected in the environment and two RFMs rename fields from levenshtein into levenstein. In this study, three simple RFMs automatically integrate the large library (and its future releases) with aforesaid environments. Abstract data types. Our running example of Figure 1 (Container class with its wrapper class Deque) leans on a configurable library of ADTs (5 features, 7 library variants) [2]. We reimplemented this feature-oriented design with RFMs 7
8
Informally, we performed primitive performance tests and found that our tool decompressed ZIP archives ∼5% faster with (fully-fletched) ZipMe than with the replaced old library, i.e., integrating ZipMe was beneficial. http://sourceforge.net/projects/openjgraph/
Refactoring Feature Modules
113
as we have shown in Figure 4. With RFMs, we can now automatically integrate differently configured library variants just by selecting refactoring features. In this study, we removed wrapper classes and methods, that provided access to classes and methods under a different name but became obsolete with RFMs. Summary. RFMs integrate well with feature-oriented refinements. RFMs allow libraries to be reused in environments they were incompatible with before. Specifically, RFMs can apply (sequences of) pre-defined refactorings to hand-written or synthesized programs automatically. After defining RFMs, any number of variants of a configurable library can be configured to be compatible with an environment. While renaming appears most important, RFMs in our perspective may encapsulate any transformation which affects structure but not semantics, e.g., ’Extract Interface’ refactoring [6] (cf. GDT study). We observed that RFMs complicate debugging because the refactored classes of the debugged program differ from the developed classes inside the feature modules. Hence, we need advanced debugging tools that keep track of the performed refactorings such that changes to the program’s classes are triggered back to the feature modules automatically.
5
Related Work
Different styles of wrapper modules (a.k.a. adapters) forward method calls to wrapped objects in order to integrate incompatible code and to increase reuse, e.g., [8,14,4]. Wrappers exist simultaneously with their wrapped objects and so a wrapper is a second way of accessing a wrapped object. RFMs transform bodies of classes such that there is no second way to access objects of a transformed class. However, RFMs avoid problems that wrappers have: Wrappers increase implementation and maintenance effort when they add methods and classes [18,9]. The forwarding methods of wrappers impact negatively on performance and footprint of the resultant program [9]. Wrappers are complex because (a) wrapper objects have different identities than the wrapped object [5,23,9] and (b) they cause type problems as their location in a type hierarchy differs from the location of the wrapped class (redundant hierarchies emerge) [9,23]. Meta-programming approaches like [20,25,3] restructure programs beyond refactoring and generally do not guarantee that generated programs are compilable. Refactoring units parameterize pre-defined meta-programs implemented globally in plugins of our composer. Therefore, developers of RFMs do not care whether generated programs are compilable (ensured by our composer). Some researchers propose refactoring meta-programs [26,13] or refactorings as language concepts [15]. They all do not integrate refactoring with feature transformations and do not provide a general model of configurable and reusable software. In order to adapt a program composed from feature modules using contemporary refactoring engines like Eclipse [7] every program variant has to be composed first and then refactorings are applied to each variant. Since possibly many (up to millions) combinations of feature modules can be composed this approach is not feasible [10]. Re-applying a common set of refactorings with such engines
114
M. Kuhlemann, D. Batory, and S. Apel
on constantly updated incompatible programs is error-prone and laborious as well [18,9]. RFMs automate refactorings and sequences of refactorings. RFMs are selected in a configuration process and thus apply at the time a program is composed (in case their feature is selected) – thus, RFMs make refactored programs available even if refactorings were not recorded for them individually. ReBA [5] helps to integrate a library into environments that use the library but rely on an outdated interface of that library. ReBA uses a trace of edits and refactorings, which lead from the old to the evolved library version. Using this trace, ReBA adds code which allows using the evolved instead of the old version, e.g., elements, that are deleted in the evolved version, are added back when referenced. RFMs can bridge incompatibilities that occur when a library A is replaced by a completely different library B. Thereby, in general no helpful trace is available, which maps all code of A to all code of B. In KIDS, users select correctness-preserving code transformations that improve performance and footprint, e.g., partial evaluation [24]. Refactoring transformations keep correctness too. When selected, RFMs restructure a program to simplify its reuse. Note, by inlining methods and classes with refactorings, RFMs may also improve performance and footprint of a composed program. Feature-oriented refactoring [16] and aspect-oriented refactoring [21] decompose a program into feature modules of a feature-oriented design and aspects respectively. In contrast, RFMs perform object-oriented refactorings on a program which is composed from features.
6
Conclusion
The structure and features (increments in functionality) of a program are important for the program to be reused by an environment. When the interface of a generated program and a client-desired interface mismatch, the generated program cannot be reused by this client. In current technology, transformations to alter the structure of programs (e.g., refactorings) and to alter the features of programs (e.g., feature modules) are still treated as disjoint concepts. In this paper, we have introduced refactoring feature modules (RFMs), which integrate feature modules with refactorings. An RFM automatically alters the structure of programs, which are composed from feature modules. We have implemented support for RFMs and demonstrated in a number of case studies that RFMs can help to reuse programs. Specifically, we showed that with RFMs the studied programs can be integrated automatically and reused in environments they were incompatible with before, i.e., RFMs simplify the reuse of code.
References 1. Batory, D., Sarvela, J.N., Rauschmayer, A.: Scaling step-wise refinement. TSE 30(6), 355–371 (2004) 2. Batory, D., Singhal, V., Sirkin, M., Thomas, J.: Scalable software libraries. In: Anderson, R. (ed.) FSE 1993. LNCS, vol. 809, pp. 191–199. Springer, Heidelberg (1994) 3. Biggerstaff, T.J.: A new architecture for transformation-based generators. TSE 30(12), 1036–1054 (2004)
Refactoring Feature Modules
115
4. Bosch, J.: Design patterns as language constructs. JOOP 11(2), 18–32 (1998) 5. Dig, D., Negara, S., Mohindra, V., Johnson, R.: ReBA: Refactoring-aware binary adaptation of evolving libraries. In: ICSE, pp. 441–450 (2008) 6. Fowler, M.: Refactoring: Improving the design of existing code. Addison-Wesley Longman Publishing Co., Inc, Amsterdam (1999) 7. Fuhrer, R.M., Keller, M., Kie˙zun, A.: Advanced refactoring in the Eclipse JDT: Past, present, and future. In: WRT (2007) 8. Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design patterns: Elements of reusable object-oriented software. Addison-Wesley, Reading (1995) 9. H¨ olzle, U.: Integrating independently-developed components in object-oriented languages. In: Nierstrasz, O. (ed.) ECOOP 1993. LNCS, vol. 707, pp. 36–56. Springer, Heidelberg (1993) 10. Krueger, C.W.: New methods in software product line practice. CACM 49(12), 37–40 (2006) 11. Kuhlemann, M., Batory, D., Apel, S.: Refactoring feature modules. Technical Report 15, Faculty of Computer Science, University of Magdeburg (2008) 12. Kuhlemann, M., Batory, D., K¨ astner, C.: Safe composition of non-monotonic features. In: GPCE (2009) 13. L¨ ammel, R.: Towards generic refactoring. In: Workshop on Rule-Based Programming, pp. 15–28 (2002) 14. Lau, K.-K., Ling, L., Ukis, V., Velasco Elizondo, P.: Composite connectors for composing software components. In: Lumpe, M., Vanderperren, W. (eds.) SC 2007. LNCS, vol. 4829, pp. 266–280. Springer, Heidelberg (2007) 15. Lewis, J.R., Shields, M.B., Meijert, E., Launchbury, J.: Implicit parameters: Dynamic scoping with static types. In: POPL, pp. 108–118 (2000) 16. Liu, J., Batory, D., Lengauer, C.: Feature-oriented refactoring of legacy applications. In: ICSE, pp. 112–121 (2006) 17. Lopez-Herrejon, R.E., Batory, D.: A standard problem for evaluating product-line methodologies. In: GCSE, pp. 10–24 (2001) 18. Mattsson, M., Bosch, J.: Framework composition: Problems, causes and solutions. In: Marie, R., Plateau, B., Calzarossa, M.C., Rubino, G.J. (eds.) TOOLS 1997. LNCS, vol. 1245, pp. 203–214. Springer, Heidelberg (1997) 19. Mens, T., Eetvelde, N.V., Demeyer, S., Janssens, D.: Formalizing refactorings with graph transformations: Research articles. Journal of Software Maintenance and Evolution: Research and Practice 17(4), 247–276 (2005) 20. Mezini, M., Seiter, L., Lieberherr, K.: Component integration with pluggable composite adapters. Kluwer Academic Publishers, Dordrecht (2000) 21. Monteiro, M.P., Fernandes, J.M.: Towards a catalog of aspect-oriented refactorings. In: AOSD, pp. 111–122 (2005) 22. Opdyke, W.F.: Refactoring object-oriented frameworks. PhD thesis, University of Illinois at Urbana-Champaign (1992) 23. Sekaraiah, K.C., Ram, D.J.: Object schizophrenia problem in modeling Is-Role-Of inheritance. In: Inheritance Workshop (2002) 24. Smith, D.R.: KIDS: A knowledge-based software development system. In: Automating Software Design, pp. 483–514 (1991) 25. Tatsubori, M., Chiba, S., Killijian, M.-O., Itano, K.: OpenJava: A class-based macro system for Java. In: Cazzola, W., Stroud, R.J., Tisato, F. (eds.) Reflection and Software Engineering. LNCS, vol. 1826, pp. 117–133. Springer, Heidelberg (2000) 26. Verbaere, M., Ettinger, R., de Moor, O.: JunGL: A scripting language for refactoring. In: ICSE, pp. 172–181 (2006)
Variability in Automation System Models Gerd Dauenhauer, Thomas Aschauer, and Wolfgang Pree C. Doppler Laboratory Embedded Software Systems, University of Salzburg Jakob-Haringer-Str. 2, 5020 Salzburg, Austria [email protected]
Abstract. Model driven engineering as well as software product line engineering are two approaches that increase the productivity of creating software. Despite the rather mature support of the individual approaches, tools and techniques for their combination, promising product specific customization of models, are still inadequate. We identify core problems of current approaches when applied to automation system models and propose a solution based on an explicit notion of variability embedded in the core of the modeling language itself.
1 Introduction Model driven engineering (MDE) is becoming increasingly popular for developing complex software intensive systems. Prominent examples include the Object Management Group’s Model Driven Architecture [1] initiative, targeted mainly at generating executable software, and MATLAB/Simulink [2], which is widely used for example in the automotive industry for designing control algorithms. Both approaches allow the user to define the behavior of a system in terms of a high-level model which is then transformed into low-level implementation code. Besides executable code, MDE may also be targeted at other artifacts such as configuration files. Our group, for example, cooperates with a provider of a specific kind of automation systems, called testbeds used for example in the automotive industry for developing combustion engines. Due to the ever changing measurement tasks during engine development, testbeds must be highly flexible and customizable. This flexibility is achieved through configuration parameters of the automation system software. Instead of the laborious and error prone process of manually configuring the automation system – a typical configuration comprises tens of thousands of individual parameter values – we apply MDE to let the users work with models of testbeds and to automatically derive configuration data. Figure 1 shows the tool chain. Since a testbed can be used for different measurement tasks, its automation system software has to be configured accordingly. Think for example of a testbed for diesel and gasoline engines. If a diesel engine is operated, all gasoline related hardware and software parts of the testbed must be disabled, and vice versa. In order to derive configuration parameters, the model must be modified each time a different task is to be performed. For a typical testbed, however, different usage scenarios can be anticipated. Instead of manually modifying the testbed model each time the measurement task changes, the testbed model could already incorporate these usage scenarios, so the model would allow choosing between predefined model variants. S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 116– 125, 2009. © Springer-Verlag Berlin Heidelberg 2009
Variability in Automation System Models
117
Fig. 1. Model driven engineering for configuration parameter generation
Expressed in terms of software product line engineering (SPLE) [3], such a testbed model represents a product line, from which specific products can be generated by making decisions at variation points. While the product line comprises the union of all possible testbed model variants, a product represents a specific testbed model from which configuration parameters can be generated. Variation points in our case are for example the choices between diesel and gasoline fuel. Products are created from reusable assets according to selections made at variation points; in our case these assets are for example model fragments representing diesel and gasoline fuel subsystems. Assets may also contain variation points, i.e. they may be parameterized. For example a diesel fuel subsystem may support weight based or flow based measurement of fuel consumption. We will use these terms throughout the rest of the paper. SPLE is concerned with two major aspects: (a) the technical representation of variability, i.e. representing assets and variation points, and (b) feature modeling, i.e. the representation of dependencies among variation points in terms of conditional expressions. Assets used in SPLE often are source code fragments, and variation points are represented as #IFDEF-like annotations within the source code. No generally applicable equivalent however is available for the case of graphical models. In the rest of the paper we thus focus on the representation of variability in a modeling evironment for testbed automation systems and only briefly touch feature models. We describe commonly used workarounds for combining SPLE and MDE and then present our own approach, which we think is applicable to other domain, too.
2 Problems of Current Approaches Although software product line engineering techniques are already applied to model driven engineering, we consider the current approaches inappropriate for automation system models. The problems stem mainly from the fact that SPLE is implemented as an add-on to existing MDE tools. This section uses examples to describe two conceptual approaches of applying SPLE approaches to MDE, and highlights their shortcomings when it comes to modeling both, software and hardware aspects which is essential for our domain. In testbed models, software aspects are represented in a graphical dataflow model; hardware aspects are represented in an electrical wiring model. 2.1 Using Dedicated Model Elements to Represent Variation Points This approach is based on positive variability where a model comprises the union of all model elements used in any of the testbed’s variants. Decisions made in the feature model are used to configure the model. Feature selection may be done through parameterization of the model in place or by creating a new model from a subset of the existing source model through some model transformation. Modeling a union
118
G. Dauenhauer, T. Aschauer, and W. Pree
model however is not always straightforward as shown in figure 2 a). The semantics of dataflow models for example usually forbids connecting multiple output signals to one input signal, so we cannot simply define both connections and choose between the connections depending on the feature model. We must find workarounds instead. An existing model can be parameterized in place through removing or changing individual model elements, for example by setting the output value of a constant block in a dataflow model to a certain value. Model elements representing variation points may be explicitly marked as fixed, optional, or variable. In case of UML, for example, stereotypes may be used, as in the PLUS approach [4]. Whole parts of a model can be enabled or disabled through model elements representing switches, for example routing output signals of multiple source model elements into one input signal of a target model element as in the Koala approach [5]. Figures 2 b) and c) show how variant specific constant values in a dataflow model can be represented in both ways. As a result of the feature selection, the existing model is altered at its variation points, reflecting the choices made.
Fig. 2. A dataflow model with variation points
Figure 2 d) shows how the final model for the example could look like if value “2” was chosen in the feature model. If the source model was figure 2 b), the constant y would be removed, along with the now unnecessary switch. If the source model was figure 2 b), the unspecified value “C” would simple be replaced by “2”. Although figure 2 b) is a possible solution to the problem of representing variability within the model, it requires additional blocks that do not stem from modeling the domain, but from the particular technical representation of variability. Such additional blocks increase the size of the model and are likely to lead to obfuscated models or “accidental complexity”, as Brooks calls it [6]. The second solution shown in figure 2 c) is less complex, but one still cannot fully understand the model until the choices made in the feature model are clear, i.e. until the value “2” is specified. In the case of dataflow models, however, this approach still is a practically used solution [7]. In contrast to the dataflow model before, we now consider an example specifying a testbed’s electrical wiring. Suppose a testbed supports two operation modes, one requiring a pressure sensor, and a second one requiring temperature sensor. Both sensors would be connected to the same plug of an I/O device. In reality, of course only one sensor may be connected to the I/O device at a time. Similarly to the case of the dataflow model, a modeling environment might prevent multiple connections to a single electrical plug in the model. As a consequence, the model fragment in figure 3 a) could not express the fact that both connections are valid in principle, but not at the same time, similarly to the dataflow example in figure 2 a).
Variability in Automation System Models
119
Fig. 3. An electrical wiring model with variation points
In contrast to the dataflow example before, it is problematic to represent the variation point by introducing an artificial switch component as shown in figure 3 b), since the model would not reflect the structure of the physical testbed anymore. This is particularly important since testbed models are not just used to derive configuration data, but also to document the system’s current state to provide guidance for testbed maintenance. Even if we would not require a hardware model to accurately represent its real world counterpart, modeling an artificial switch still introduces accidental complexity. 2.2 Creating Products by Merging Assets in Multiple Model Fragments An alternative technique for representing positive variability is using multiple assets representing model fragments. One specific testbed model can then be created by merging these fragments into a single model, as illustrated in figure 4.
Fig. 4. Dataflow models created by merging multiple fragments
We use the dataflow example from the previous section; the electrical wiring example can be modeled analogously. Figure 4 a) represents a fragment containing the common functionality where one of the controller’s inputs is not yet connected; figures b) and c) are two additional fragments containing the variant specific elements to be merged in. The complete model shown in figure 4 d) is the result of merging fragment a) and b), while model e) is created from fragment a) and c). In order to be able to merge fragments automatically, e.g. by a dedicated external SPLE tool, models of the fragments must contain some uniquely identifiable shared elements. In our example, fragment b) and c) both contain a PID controller. Since the common model fragment a) also contains an equal controller block, they can be merged unambiguously by partially replacing the definition of the controller in the common fragment. If no such shared element could be identified, merging could not be performed automatically. As a consequence, fragments must be kept in sync, which may not always be straightforward if they are stored in different files, edited by different users. Another consequence of using multiple, technically independent assets is that the “big picture” of the model is lost. Consistency checks for example, e.g. compatibility
120
G. Dauenhauer, T. Aschauer, and W. Pree
between dataflow signals, can be performed only locally for each fragment; the overall consistency can not be checked until they are merged together according to a particular selection in the feature model. The resulting cycle of “feature selection, model merge, and consistency check” is cumbersome. In practice, this situation usually is avoided by encoding such technical requirements into the feature model, leading to complex feature dependencies that are intermixed with business decisions. Maintaining the feature model then becomes difficult and error-prone, since in-depth technical knowledge as well as business-specific knowledge is required.
3 Modeling Language with Built-In Support for Variability In the previous section we used examples to identify problems that arise when using a modeling language that does not provide direct support for representing variability. We now describe how a modeling language could support variability from a user’s perspective. Our approach is related to the modeling approach using multiple model fragments as described in section 2.2. Instead of using technically independent assets, such as different files, we treat them as conceptual entities defined within one single model, in order to avoid the disadvantages of that approach. We start with a model defining the common behavior. We then explicitly define the variation points with additional fragments and define their behavior as an extension of the common model. Picking up the example from figure 2, figure 5 shows how our approach can be applied to define the dataflow model: a) describes the common behavior, b) and c) are each defined by incrementally defining the variations.
Fig. 5. Explicit variations in the dataflow models
Note that the first input port of the PID controller in fragment a) is not yet connected. Incremental fragments b) and c) only define the constant block and the connection to the PID controller in the common model. The PID controller drawn in dashed lines and any other model elements defined by the common fragment are fixed since the model fragment for a variation may only introduce additional behavior. Instead of introducing fragment specific model elements as used in figure 5 that differ only in their parameter values, we explicitly provide a means for representing fragment specific parameter values. Figure 6 shows how our example could be represented more concisely. Fragment a) again is the common behavior, now however it already contains a constant block with a default value explicitly marked as modifiable in variants. Fragments b) and c) only redefine the parameter value. They do not introduce additional model elements anymore.
Variability in Automation System Models
121
Fig. 6. Explicit variation of parameter values
Figure 7 shows a hardware example corresponding to figure 3. Note that no artificial switch component from figure 3 b) is needed anymore, and both wire connections from sensors x and y to the I/O device’s input plug can be represented without contradictions. Again, a) represents the common behavior, where models b) and c) represent the fragments using different sensors, where the common behavior is fixed.
Fig. 7. Explicit variation in the electrical wiring model
The main difference to the merging approach described in section 2.2 is that in our approach the common model and the fragments all share the same model elements. There are no model elements that must be kept in sync in order to merge fragments correctly. In our example, variations 3 and 4 both reference the same single I/O device element in the model. Another major difference is that in our approach, the fragments describing the variations extend the common model fragment and as such more consistency checks can be performed in context. For example, in variations 3 and 4, not only the fact is modeled that sensor x or y is connected to the I/O device, but in addition, the whole signal chain from the sensors to the automation system can be traced and checked for consistency, e.g. for proper encoding of sensor data on bus messages between the I/O device and the automation system. By keeping all fragments within the same model, we however face the disadvantage that individual fragments can not be used outside their anticipated scope. Additionally, model fragments can not be created in a distributed environment without further support of the modeling environment. We think that such restrictions are acceptable, though. 3.1 Variation Points and Feature Modeling Although feature modeling is not the main focus of scope of this paper, we however briefly describe how our modeling approach affects feature modeling. Similarly to the approach in section 2.2, we create a complete testbed model by merging together multiple model fragments. The fragments to merge may be selected manually or they may be defined by choices made in the feature model. Feature models are used to express logical dependencies among variation points in a model. Fragments from figure 4 b) and c) for example cannot be merged, since they contain contradicting definitions for constant values. The same holds true for our fragments 6 b) and c).
122
G. Dauenhauer, T. Aschauer, and W. Pree
While in the conventional approaches for combining SPLE with MDE such dependencies have to be modeled explicitly, in our approach these technical conflicts can already be derived from the model. Table 1 shows the tabular representation of model elements and fragments from our example in figure 5 and 6. Table 1. Variants in tabular form describing their model elements
Model element constant controller sensor x sensor y I/O device automation system …
common 4 9 9 9 …
+ var. 1 2 9
…
+ var. 2 5 9
…
+ var. 3 4 9 9 9 9 …
+ var. 4 4 9 9 9 9 …
Model elements such as constant, controller, I/O device, and automation system are used in the common fragment, but sensor x and sensor y are not. The constant is used also in variation 1 and 2 representing dataflow model fragments with a value of “2” and “5” respectively. It is also implicitly used in variation 3 and 4 with the default value defined in the common fragment. From these definitions, one can automatically derive that variation 1 and 2 cannot be used simultaneously. The controller is used unmodified in variation 1 and 2 and again implicitly used in variation 3 and 4. Note that the connections between model elements representing signal flows or electrical wires are also model elements but are skipped here; they would also be explicitly marked present or missing in each of the fragments. Note that the model with its variation points does not yet define a complete feature model. For example we described “common + variation 1”, as well as “common + variation 3”, but did not make statements about whether these variations can be active simultaneously. But since there are no conflicts visible in the table, these fragments may technically both be used together. We currently do not care whether merging these fragments make sense from e.g. a business perspective though. We think that manually creating a testbed model from fragments like this, i.e. by enabling “columns” from the table is a possible first step to a full-featured product line support in our modeling environment. We thus consider presenting such a tabular view to the users as the means for configuring testbed models; a feature model, however, could be defined on top of this technical basis later on. 3.2 Variation Points of Model Elements So far we have described how a model can be created by enabling model fragments, i.e. by selecting which model elements to use, how to connect them and what their parameter values should be. As motivated in the introduction, model elements may themselves come in multiple variants. Their variants are chosen in the same way as described above. After all, model elements and the testbed model are not different in a technical sense; a testbed model itself is also just a model element that could in principle be used in a model of a factory. As an example, consider a testbed model that
Variability in Automation System Models
123
contains a diesel fuel system model element. This system may come with weight or flow based measurement of fuel consumption and as such defines one variation point.
4 Model and Variability Representation In order to sketch how we implement variability, we first introduce the language’s existing implementation core. Similar to other modeling languages such as the UML [8] with MOF [9] as its core, our modeling language uses a set of core of primitives. Our language, however, is based on a unification of classes and objects known as clabjects [10, 11]. White boxes in figure 8 represent a simplified view on our modeling language core, which is sufficient for our discussion here. enables Variant
enables contains
Clabject
target
Connector
source
requires
contains enables
Field
contains
Fig. 8. Clabject based modeling language core
Clabjects are used to represent model elements that users work with, for example sensors and I/O devices. A clabject may represent either a type or an instance. A clabject can be associated with another clabject by means of a connector, for example an I/O device may contain electrical plugs. A connector also may represent either a type, e.g. specifying cardinality, or an instance, i.e. a link between two clabjects representing instances. A connector may either represent composition of a clabject and its contained clabjects, or it may represent general associations between clabjects. Both, clabject and connector can have fields for representing parameter values, for example the value of the constant in our dataflow example. Again, a field may be either a type specifying e.g. the data type, or an instance specifying a value. Each of the basic elements, clabject, connector, and field, has another relation that allows defining subtype and instantiation relations between elements; these relations are skipped here to reduce clutter. Although the modeling language core does not define semantics of a specific domain, our modeling environment however ensures that the models are consistent, i.e. that for example the connector instances are established between compatible clabject instances and that the model adheres to the multiplicity constraints. The examples in section 3 informally introduced the kinds of variability we support in our modeling language. These are: (1) enabling/disabling connections, for example between the sensors and the I/O device in figure 7, (2) enabling/disabling model elements, for example the different sensors in figure 7, (3) enabling/disabling variant specific field values, for example the constant values in figure 6, and (4) enabling/disabling of variants of contained model elements, for example the fuel consumption measurement. The basic model is thus extended with an explicit notion of one or more variants; one variant is always implicitly defined as the common variant. The clabject representing e.g. a whole testbed thus contains the union of all clabjects, connectors and fields used in any of these variants. The enables relations between a
124
G. Dauenhauer, T. Aschauer, and W. Pree
variant and a subset of the clabjects, connectors and fields now explicitly define which of these parts it requires. Two additional relations are defined for the variant: an enables relation is used to chose between variants of a contained clabject, while the requires relation is used to represent the DAG of variant dependencies. Using this basic mechanism, we can represent the different kinds of variation easily: (1) can be represented straightforwardly by an enables relation between a variant and a connector instance. (2) can be represented in the same way by an enables relation between a variant and a connector instance; note that the containment of clabjects is represented by connectors, too. (3) can be represented by an enables relation between the variant and a specific field value. (4) can be represented by an enables relation between the clabject’s variant and a variant of a contained clabjects.
5 Related Work Voelter and Groher [12] use the terms negative and positive variability to describe how models are constructed. Negative variability, uses a model from which unnecessary features are selectively removed to get a specific model. Positive variability, in contrast, uses a core model to which features are added. SPLE in MDE often is done by configuring models according to the choices made in an external tool. pure::variants Connector is such a tool for MATLAB/Simulink [13]. It imports Simulink blocks as assets into the separate feature modeling tool. For a certain feature selection the corresponding Simulink blocks are added, removed, or their parameters are set, and also signals, i.e. connections between blocks, can be created or deleted. Thus this product supports positive as well as negative variability. BigLever provides an analogous commercial Bridge solution [14] for integrating Telelogic’s Rhapsody [15] UML and SysML modeling tool into their Gears SPLE tool. Elements in a Rhapsody model are turned into variation points, managed by Gears. Thus this commercial product supports negative variability. Creating models from fragments seems to be less well supported. Voelter and Groher [12], for example describe a solution based on positive variability using aspect oriented software development. Among their assets are models that are merged or woven together according to a feature model. Straw et al. [17] show how UML-like class models can be merged, while Herrmann et al. [16] present an algebraic view on model composition.
6 Conclusion In this paper we motivated why a modeling environment for automation systems should support variability of models. We first described why we consider existing SPLE approaches insufficient in this context. We introduced our alternative approach from a user perspective first and briefly outlined how it could be integrated seamlessly with our clabject based modeling language core. We already have implemented the modeling environment and demonstrated its applicability to the domain. We did however not yet implement the variability support. Although we described variability using examples from the engine testbed domain, we expect that our approach can be applied to other sufficiently complex domains as well.
Variability in Automation System Models
125
References 1. OMG Model Driven Architecture, http://www.omg.org/mda 2. The MathWorks MATLAB/Simulink, http://www.mathworks.com/products/simulink 3. Clements, P., Northrop, L., Northrop, L.M.: Software Product Lines: Practices and Patterns. Addison-Wesley Professional, Reading (2001) 4. Gomaa, H.: Designing Software Product Lines with UML: From Use Cases to PatternBased Software Architectures. Addison Wesley, Redwood City (2004) 5. van Ommering, R., van der Linden, F., Kramer, J., Magee, J.: The Koala Component Model for Consumer Electronics Software. Computer 33(3) (2000) 6. Brooks, F.P.: No Silver Bullet Essence and Accidents of Software Engineering. In: Computer, vol. 20/4, pp. 10–19. IEEE Computer Society Press, Los Alamitos (1987) 7. Dziobek, C., Loew, J., Przystas, W., Weiland, J.: Von Vielfalt und Variabilität – Handhabung von Funktionsvarianten in Simulink-Modellen. In: Elektronik Automotive, vol. 2, pp. 33–37. WEKA Fachmedien GmbH (2008) 8. Object Management Group: Unified Modeling Language Superstructure, v 2.1.2 (2007) 9. Object Management Group: Meta Object Facility, http://www.omg.org/mof 10. Atkinson, C., Kühne, T.: The Essence of Multilevel Metamodeling. In: Proceedings of the 4th International Conference on the Unified Modeling Language, Modeling Languages, Concepts, and Tools, pp. 19–33. Springer, Heidelberg (2001) 11. Aschauer, T., Dauenhauer, G., Pree, W.: Multi-Level Modeling for Industrial Automation Systems. 35th Euromicro Conference on Software Engineering and Advanced Applications (to appear, 2009) 12. Voelter, M., Groher, I.: Product Line Implementation using Aspect-Oriented and ModelDriven Software Development. In: Proceedings of the SPLC 2007, pp. 233–242. IEEE Computer Society, Los Alamitos (2007) 13. pure systems: pure:variants Connector for MATLAB®/Simulink® (2009), http://www.pure-systems.com 14. BigLever Telelogic Rhapsody® GearsTM Bridge (2009), http://www.biglever.com/extras/Rhapsody_Gears_Data_Sheet.pdf 15. Telelogic Rhapsody® (2009), http://modeling.telelogic.com/products/rhapsody 16. Herrmann, C.A., Krahn, H., Rumpe, B., Schindler, M., Völkel, S.: An algebraic view on the semantics of model composition. In: Akehurst, D.H., Vogel, R., Paige, R.F. (eds.) ECMDA-FA. LNCS, vol. 4530, pp. 99–113. Springer, Heidelberg (2007) 17. Straw, G., Georg, G., Song, E., Ghosh, S., France, R., Bieman, J.: Model Composition Directives. In: Baar, T., Strohmeier, A., Moreira, A., Mellor, S.J. (eds.) UML 2004. LNCS, vol. 3273, pp. 87–94. Springer, Heidelberg (2004)
A Case Study of Variation Mechanism in an Industrial Product Line Pengfei Ye1, Xin Peng1, Yinxing Xue2, and Stan Jarzabek2 1
School of Computer Science, Fudan Univeristy, Shanghai, China {072021110,pengxin}@fudan.edu.cn 2 School of Computing, National Univeristy of Singapore, Singapore {yinxing,stan}@comp.nus.edu.sg
Abstract. Fudan Wingsoft Ltd. developed a product Line of Wingsoft Financial Management Systems (WFMS-PL) providing web-based financial services for employees and students at universities in China. The company used a wide range of variation mechanisms such as conditional compilation and configuration files to manage WFMS variant features. We studied this existing product line and found that most variant features had fine-grained impact on product line components. Our study also showed that different variation mechanisms had different, often complementary, strengths and weaknesses, and their choice should be mainly driven by the granularity and scope of feature impact on product line components. We hope our report will help companies evaluate and select variation mechanisms when moving towards the product line approach.
1 Introduction The goal of this paper is to evaluate strengths and weaknesses of variation mechanisms used in the existing Wingsoft Financial Management System 1 Product Line (WFMS-PL), developed by Fudan Wingsoft Ltd., a small software company in China. We took the following steps in this study. We first analyzed WFMS-PL variant features [7] and presented them as a feature diagram [10]. Then, we studied variation mechanisms in WFMS, namely Java conditional compilation2, commenting out feature code, design patterns [4], parameter configuration files, and a build tool Ant3. Finally, we analyzed how the granularity and scope of features impact on WFMS components affects the effectiveness of variation mechanisms. We distinguish two types of features according to the granularity of their impact, namely fine-grained features affecting many system components, at many variation points, and coarse-grained features whose code is usually contained in files that are included into a custom product that needs such features. Mixed-grained features involve both fine- and coarse-grained impact. Most of the WFMS features were 1
WFMS for Shanghai Jiaotong University: http://www.jdcw.sjtu.edu.cn/wingsoft/index.jsp Java does not formally have conditional compilation, but you can implement the similarfunction: http://c2.com/cgi/wiki?ConditionalCompilationInJava 3 http://ant.apache.org/ 2
S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 126–136, 2009. © Springer-Verlag Berlin Heidelberg 2009
A Case Study of Variation Mechanism in an Industrial Product Line
127
fine-grained features, managed with conditional compilation and/or manually commenting out the feature code. Our study shows that different variation mechanisms have different, often complementary, strengths and weaknesses, and their choice should be mainly driven by the granularity and scope of feature impact on product line components. Fundamental differences in capabilities of variation mechanisms justify the use of multiple variation mechanisms. For example, Ant is strong in configuring coarse-grained features, but weak in configuring fine-grained features. Parameter configuration files define environmental variables and variant feature options, but require yet other mechanisms to perform the actual customizations in product line components. Design patterns reduce the coupling in code, making it easier to add, remove or change a variant feature. However, we found only few opportunities to apply design patterns in WFMS. Overloading fields in order to use the same field for different purposes usually helps only in configuring database schema. Conditional compilation is used as the main mechanism to control fine-grained variant features in Java source code, while commenting out feature code is heavily used in HTML and JSP files. In some situations, we suggest possible remedies to weaknesses of variation mechanisms used in WFMS-PL. Particularly, multiple variation mechanisms must be used to manage each of the mixed-grained features. Our study reveals that while it is natural to match feature granularity with the proper variation mechanism, over time the inter-play between multiple variation mechanisms may be difficult to comprehend. Variation mechanisms used in WFMS-PL are simple, freely available and commonly used in Software Product Lines (SPL) to complement component/architecturebased approaches. As yet we do not have enough material to compare them with more advanced SPL approaches, such as GEARS4, Pure5 or XVCL [6], with possibly better results. We are going to conduct experiments to facilitate such comparison. In the past years, there were some case studies on variation mechanism. These studies, however, usually focused on variation implementation with certain techniques like AspectJ [13], FOP [1] or XVCL [6]. The industrial case study presented in [17] aims at architecture-based variability realization in large companies. In this paper, we analyze a real product line using a mixed set of light-weight variability mechanisms in a small company. We believe Wingsoft choice of variation mechanisms was typical, and other small companies may find our experiences reported in this paper useful when moving towards the product line approach.
2 An Overview of WFMS WFMS was developed in 2003 and evolved to an SPL with more than 100 customers today, including major universities in China such as Fudan University, Shanghai Jiaotong University, Zhejiang University. During its evolution, Wingsoft set up product architecture and was adopting variation mechanisms such as Java conditional compilation, Ant, parameter configuration files, and design patterns to manage product variability. 4 5
GEARS: http://www.biglever.com/ Pure::Variants: http://www.pure-systems.com/
128
P. Ye et al.
The core assets of the WFMS-PL were designed and implemented by few domain engineers. Domain engineers sometimes also played the role of an application engineers responsible for initial, program-level customization of core assets for a custom product. Service engineers, familiar with financial business but with little or no programming knowledge, did final customer-side customizations and deployment, using readable parameter configuration files. Usually, application engineers only provided in-office application-specific implementations, and responded to requests of service engineers. Domain engineers maintained WFMS products for many customers delegating routine work to service engineers. WMFS consists of four subsystems, namely Financial Management Subsystem (FMS), Salary Management Subsystem (SMS), Reward Management Subsystem (RMS), and Tuition Management Subsystem (TMS). We selected the TMS for our case study, as it involved types of variability and variation mechanisms that were representative of the whole WFMS. TMS is a web-based portal for students to pay online their tuition fee, with functions such as login, fee browsing, online payment, payment detail generation and bank settlement. The code of TMS is 25% of the whole WFMS system, comprising 58 Java source files, 99 JSP web pages, and several configuration files. A WFMS feature diagram is shown in Fig. 1. The minimum and maximum choices of OR-features are shown as numbers surrounded by square brackets. 80% of the 32 variant features can be selected for custom TMS. However, there are also some feature interactions. For example, the selection of InitPayMode depends on the number of selected variant features under FeeItemSelection and the selection of Settlement depends on whether selected banks require settlement. TMS features include fine-, coarse, and mixed-grained features.
Fig. 1. The feature diagram of TMS
3 Variation Mechanism in TMS 3.1 Review of Variation Mechanism in TMS Five variation mechanisms shown in Table 1 were used to manage variant features in TMS. In the table, column “# Features” indicates the number of features whose
A Case Study of Variation Mechanism in an Industrial Product Line
129
customizations involved a given technique. Ant, conditional compilation and commenting out variant feature code were most commonly used. Java conditional compilation and commenting out code: In Java, conditional compilation is realized with final-boolean variables. If a final-boolean variable’s value is false, then the code in the statements under if is not compiled into the generated bytecode file. The effect is similar to #define and #ifdef C/C++ preprocessor directives [15]. Fig. 2 illustrates the usage of final-boolean variables to manage variant features in TMS class FeatureConfiguration. The limitation of Java’s conditional compilation is that it can only be used in inner-method statements. It cannot handle the inclusion or exclusion of class methods or attributes. In WFMS, such cases were handled by manually commenting out the code that was not required in a given product variant. Commenting out was also used in non-Java files such as JSP files or SQL script. The main reason for such practice was that the engineers at Fudan Wingsoft could not find flexible tools to manage variability in these files at that time. Table 1. Feature numbers for variability techniques used in TMP # Techniques Conditional compilation & comment Ant Overloading fields configuration items Design Pattern & reflection
1 2 3 4 5 1 2 3 4 5 6 7 8 9 10 11 12 13 14
# Features 31 19 13 12 3
public class FeatureConfiguration { // Configuration items public static final boolean DelegationLock = true; public static final boolean OperationLock = true; } public class FeeInfo { ... public void initInfo(FeeUser user, boolean isPaidFeeInfo) throws Exception { //get each year’s fee items for( int i=0; i < yearTemp.size(); i++ ) { If ( FeatureConfiguration.DelegationLock && FeatureConfiguration.OperationLock ) // Code when both features are selected else if ( FeatureConfiguration.DelegationLock ) // Code when delegationLock is selected else if ( FeatureConfiguration.OperationLock ) // Code when operationLock is selected } } }
Fig. 2. Managing variant features with Java’s final-boolean mechanism
Design patterns and reflection: [14] has described the use of the abstract factory pattern in SPL. It also extended this concept using the dynamic abstract factory pattern, in which concrete factories were adapted to support new concrete products at run-time by adding Register and UnRegister operations to Abstract Factory for each
130
P. Ye et al. 1 2 3 4 5 6 7 8 9 10 11 12 13
public class FeeOrder { private Initializer initializer; public init(FeeUser user, FeeInfo info, HttpServletRequest request) { Class c; try{ c = Class.forName( user.getPayMode() ); initializer = (Initializer) c.newInstance(); initializer.init ( . . .); } catch(Exception e ) { e.printStackTrace(); } } }
Fig. 3. Reflection used in strategy pattern
abstract product. Although the most frequently used design patterns in TMS were AbstractFactory with FactoryMethod and Strategy, reflection mechanism, instead of operations returning name of product, was also used to dynamically instantiate proper concrete instances according to configuration options so that the specific class names could be abstracted from the source code. Then Ant could be used to control the inclusion and exclusion of a strategy subclass. Fig. 3 shows the use of Strategy Pattern in TMS. Overloaded Fields: Variant features affect TMS database schema. Overloading table fields helps to contain some of those impacts. For example, a table may have several fields named spec_1, spec_2 ... spec_n, and the same filed may be used to store bank card number in one product variant and ID card number in another one. There were also tables and fields that make sense for some product variants, but are useless for others. With overloading fields, all the products could share the same DB schema, but still support different data structures required for variant features. Overloading fields was adopted for WFMS-PL database. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<project name="webfee" basedir="." default="main"> <project>
Fig. 4. Using Ant to include optional features
Ant: An important class of configuration parameters was managed by Ant. [3] used Ant and configuration files to differentiate variability in process and variability in product. Lower layers always override the build.xml file of upper layers, by which only the build.xml of the leaf layer will take effect. By reading layer orders in configuration files, the leaf layer can be determined. In WFMS, Ant was useful as a
A Case Study of Variation Mechanism in an Industrial Product Line 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
131
<webFee> <paymode>PayByItem ICBC CCB CMB http: //mybank.icbc.com.cn/servlet/co... C: /apache-tomcat-5.5.25/webapps/… 12345678 <merchantid>440220500001 true
Fig. 5. Using configurations files
variation mechanism for coarse-grained variant features as Ant can be used to control the inclusion/exclusion of not only java source files but also JSP files and security certificates. For instance, optional feature DownloadPaymentDetail of TMS was managed by Ant as shown in Fig. 4. This feature was implemented by a Java class and a JSP file. The inclusion of this feature in a customized product was implemented by moving the relevant files from the path of core asset to the path of javac command in the Ant configuration file. Parameter Configuration Files: In TMS, self-defined configuration files were also employed as a variation mechanism, as shown in Fig. 5. Configuration files contained both data and control parameters. Data parameters, such as URLs of banking services and key path, were also widely used in single products. Control parameters feature to be selected for a custom product, while other variation mechanisms were used to perform the actual selection. For example, the parameter paymode in Fig. 5, indicating the right sub-class to be initialized, worked together with the reflection and the strategy pattern shown in Fig. 3 (see the underlined part). Another example of parameters working with other variation mechanisms is the parameter DownloadDetail in Fig. 5. A simple tool was implemented to read this parameter and generate Ant script shown in Fig. 4 if the value is true. 3.2 Summary of Variation Mechanism in TMS Fig. 6 shows which variant features were managed using which variation mechanisms. We do not show overloading fields which was used for variants in database table schema only and did not overlap with other mechanisms. More than 80% features (26 among 32) were managed by more than one variation mechanism: 13 features were managed by three mechanisms and three features by four mechanisms. Design patterns were always used together with other mechanisms. Another interesting observation is that almost all features involved the use of conditional compilation and/or commenting out feature code, as in WFMS, like in many other SPLs, we saw many fine-grained features.
132
P. Ye et al.
Fig. 6. Variation mechanisms per feature
For mixed-grained features, a combination of several variation mechanisms was usually used. For example, when we include a source files for a selected variant feature with Ant, we still need conditional compilation to configure corresponding caller in the base code. Table 2 summarizes the usage, scope, merits and drawbacks of various variation mechanisms used for WFMS-PL variant features. It is interesting to compare traditional variation mechanisms, such as described in this paper, and more advanced ones such as XVCL [6], AspectJ [13] or FOP [1]. It also will be the next step of our work.
4 Evaluation of the WFMS-PL and Possible Improvements Projecting experiences from TMS study, we now evaluate WFMS-PL variability management strategies from the perspectives of feature granularity, ease of applying, readability and managing the consistency between WFMS core assets and custom products. On overall, we found that the current WFMS-PL strategies for variability management properly matched the feature granularity. The newcomers to the team could easily understand when and how to apply them. However, over time when the impact of many features was accumulating, the readability of the WFMS-PL has suffered, and it was becoming difficult to trace features to code and manage features consistently. The detailed reasons and suggested remedies are given in the following paragraphs.
A Case Study of Variation Mechanism in an Industrial Product Line
133
Table 2. Summary of variation mechanism in WFMS-PL Variation Mechanism
Usage
Conditional compilation & Comments
Using Final-Boolean mechanism in Java and natural language comments
Design Pattern
To gain good modularization in OO source code Used together with Java Reflection and Ant
Overloading Fields
Scope Final-Boolean method is only used on innermethod statements. Comments can be adapted to all places Class or method level Best to gain class level flexibility in OOP part of a product line.
Making all the customized products share the same Database table schema attribute in database
Merits
Drawbacks
Easy to learn and use
All maintain works and configurations are manual. Sub-paths explode as the number of tangled features increases.
Providing Elegant code, High readability, Good Extendibility.
Scope of application is narrow and always need the aids of other techniques.
Avoiding troubles to change the name of attributes
Hard to maintain, easy to cause confusion about the meaning of the fields
Configuration File
Implementing the configuration of various parameters according to the variant feature selection and environmental change
Giving parameters of the Good mechanism to variant feature selections do feature configuraand the environment tion
Ant
Conditionally compiling java source files and building deployments
System level customization Dealing with all kinds of files
Powerful and popular build tool, flexible to deliver product variants
It needs to cooperate with other methods and introduces the nontraceability issue. Many inter-dependent configuration parameters
Only file-level variants
Feature granularity: Feature granularity is a critical factor that guides selection of variation mechanisms as feature characteristics must be matched by the capabilities of a variation mechanism(s) used to manage a given feature. In WFMS-PL, fine-grained features were managed by conditional compilation in Java code, and with commenting out code section in other WFMS artifacts. Ant was used to manage coarse-grained features at the level of package or class inclusion/exclusion level. Design pattern played the role of a class or method extension mechanism. In Table 3, we show the number of WFMS variation points for each feature impact granularity level. Finegrained impacts of features required small changes in Java expressions, statements, method signatures, comments (in Java code, JSP or HTML), database table scripts, and parameter configuration files. Medium-grained impacts required changes of Java methods or attributes, changes of database table scripts, and changes of configuration items in parameter configuration files. Coarse-grained impacts required inclusion or exclusion of product-specific source files. Fine-grained features trigger most of the problems. Conditional compilation and commenting out feature code was used to manage fine-grained impacts. A big problem is how to trace variant features down to the many variation points relevant to them. This problem aggravates when multiple variation mechanisms are used to manage a given feature. Some feature enhancements involve changes at many variation points that must be properly coordinated. WFMS engineers often encountered the problems of inconsistent product release, e.g., a product variant was deployed with incorrect database schema. Fine-grained and coarse-grained features were most common. We try to analyze the reasons as follows: Coarse-grained impacts are easy to configure. Whenever possible, domain engineers tried to contain the variant feature code in separate files which could then be included into custom products that required those features. Wizards could be implemented to allow application/service engineers to easily include such features into
134
P. Ye et al.
custom products. Fine-grained impacts are attributed to the variability of the business flow or logic of the application itself and of the programming languages. However, fine-grained features made it more difficult to consistently manage the overall product configuration. They often affected coarse-grained features and the new variation points had to be injected into the source code of coarse-grained features. Table 3. The number of variation points per impact granularity level Granularity
#Java
#JSP
#Conf. File
#DB Schema
Finest
14
0
0
0
#Total 14
Fine
67
43
3
3
116
Medium
18
0
7
5
30
Coarse
40
57
9
0
106
#Total
139
100
19
8
266
Ease of application: Customizations of core assets by configuring parameters and database schemas could be managed by service engineers who were in charge of deployment of a customized product on the customer site. Service engineers were familiar with general financial domain, user requirements, and basic deployment operations, but did not know much about programming and internals of the WFMSPL. Wizard-supported parameter configuration files provided an easy-to-use configuration capability for service engineers. Ease of application without involvement of any unconventional or proprietary techniques was the most important reason for Fudan Wingsoft to adopt simple and commonly available variation mechanisms for WFMS-PL. This reduced the learning curve and the staff training cost, important factors for any small or middle-sized company. Unless current mechanisms were found totally ineffective, Wingsoft would be chary of adopting new ones. WFMS-PL was constructed in lightweight, reactive way, which was in line with the company’s benefits so far. Readability: Design patterns and Ant did not hinder readability, but conditional compilation, commenting our feature code and overloading fields made code difficult to understand for applications engineers and even domain engineers. In our project, 30% of code in class FeeOrder, 20% of code in FeeInfo and 35% of code in FeeUser was managed by Java conditional compilation. Given that there are no other techniques to manage fine-grained features, this problem is very hard to solve. If we keep the code of variant feature code embedded in the base code, the code is bound to become hard to read. One can consider Aspect-Oriented Programming (AOP) [13] or Feature-Oriented Programming (FOP) [1] to separate features from the base code, but these approaches pose new problems as demonstrated in [11] and [12]. To improve the readability of the code, a promising approach is to resort to visualization tool’s support such as CIDE [12] or [8]. Traceability and extensibility: Traceability between features and their respective variation points has to do with both feature reuse and evolution. Here are some examples of problems:
A Case Study of Variation Mechanism in an Industrial Product Line
135
•
Each feature may be addressed at many variation points scattered through many SPL core components. To reuse or modify the feature we must find and analyze code at all these points. • One SPL core component is usually affected by many features that may be managed by different possibly overlapping variation mechanisms. To reuse or modify the feature we must understand interactions among these mechanisms. Variation mechanisms described in this paper provide a workable but not perfect solution for traceability problems. Table 4 shows features that involved several variation mechanisms, with their respective variation points spread across different WFMS-PL core components. How to manage these variation points consistently was the issue of traceability. The difficulty in traceability also brought in the problem of product extensibility at those variation points. Table 4. The number of variation points in example features Variant Feature
Preprocessing
Conf. Files
Ant
Total
WebService-Payment
6
2
2
10
ABC
2
1
3
6
CCB
1
1
2
4
CMB
2
1
2
5
ICBC
1
2
3
6
Yet another traceability problem that has to do with two-way propagation of changes between SPL core components and customized product variants [15]. This problem often hinders reuse, and we believe it is difficult to address it in the frame of variation mechanisms described in this paper. A meta-level representation of the SPL core components paves the way for more effective solutions to these problems [9]. They can capture and manage synchronously the overall impact of features on SPL core components [5].
5 Conclusion In this paper, we evaluated strengths and weaknesses of variation mechanisms used in Wingsoft Financial Management System Product Line (WFMS-PL), developed by Fudan Wingsoft Ltd. Feature characteristics must be matched by the capabilities of variation mechanism(s) used to manage a given feature. Fundamental differences in capabilities of variation mechanisms justify the use of multiple variation mechanisms. Our study confirmed that different variation mechanisms have different, often complementary, strengths and weaknesses. Their choice should be mainly driven by the granularity and scope of feature impact on product line components. In some situations, we suggested possible remedies to weaknesses of variation mechanisms used in WFMS-PL. Our study revealed that while it was natural to match feature granularity with the proper variation mechanism, over time the inter-play between multiple variation mechanisms may become difficult to comprehend. Variation mechanisms used in WFMS-PL are simple, practical, commonly used in SPLs to complement component/architecture-based approaches. We hope our report
136
P. Ye et al.
will help companies to make more informed decisions when moving towards the product line approach. In follow-up study, we compare the original WFMS-PL with a representation built with XVCL [6] as a variation mechanism, and plan to extend our study to other SPL approaches. Acknowledgement. This work was supported by Fudan University grant (the National Natural Science Foundation of China under Grant No. 60703092, the National High Technology Development 863 Program of China under Grant No. 2007AA01Z125, and Shanghai Leading Academic Discipline Project under Grant No. B114) and National University of Singapore grant R-252-000-336-112.
References 1. Batory, D., Sarvela, J.N., Rauschmayer, A.: Scaling Step-Wise Refinement. IEEE Transactions on Software Engineering 30(6) (2004) 2. Bosch, J., Florijn, G., Greefhorst, D., Kuusela, J., Obbink, H., Pohl, K.: Variability Issues in Software Product Lines. In: van der Linden, F.J. (ed.) PFE 2002. LNCS, vol. 2290, p. 13. Springer, Heidelberg (2002) 3. Díaz, Ó., Trujillo, S., Anfurrutia, F.I.: Supporting Production Strategies as Refinements of the Production Process. In: Obbink, H., Pohl, K. (eds.) SPLC 2005. LNCS, vol. 3714, pp. 210–221. Springer, Heidelberg (2005) 4. Gamma, E., Helm, R., Johnson, R., Vlissides, J.: Design Patterns. Addison-Wesley Professional, Reading (1995) 5. Jarzabek, S.: Effective Software Maintenance and Evolution: Reuse-based Approach. CRC Press Taylor & Francis, Boca Raton (2007) 6. Jarzabek, S., Bassett, P., Zhang, H., Zhang, W.: XVCL: XML-based variant configuration language. In: ICSE 2003 (2003) 7. Jarzabek, S., Ong, W.C., Zhang, H.: Handling Variant Requirements in Domain Modeling. Journal of Systems and Software 68(3) (2003) 8. Jarzabek, S., Zhang, H., Lee, Y.P., Xue, Y., Shaikh, N.: Increasing Usability of Preprocessing for Feature Management in Product Lines with Queries. Accepted for ICSE 2009 poster 9. Jirapanthong, W., Zisman, A.: XTraQue: Traceability for Product Line Systems. Software and System Modeling 8(1) (2009) 10. Kang, K.C., Lee, J., Donohoe, P.: Feature-oriented Product Line Engineering. IEEE Software 19(4) (2002) 11. Kästner, C., Apel, S., Batory, D.: A Case Study Implementing Features Using AspectJ. In: SPLC 2007 (2007) 12. Kästner, C., Apel, S., Kuhlemann, M.: Granularity in Software Product Lines. In: ICSE 2008 (2008) 13. Kiczales, G., Lamping, J., Mendhekar, A., Maeda, C., Lopes, C.V., Loingtier, J.-M., Irwin, J.: Aspect-Oriented Programming. In: Aksit, M., Matsuoka, S. (eds.) ECOOP 1997. LNCS, vol. 1241, pp. 220–242. Springer, Heidelberg (1997) 14. Linden, F., Schmid, K., Rommes, E.: Software Product Lines in Action: The Best Industrial Practice in Product Line Engineering. Springer, Heidelberg (2007) 15. Pohl, K., Böckle, G., Linden, F.J.: Software Product Line Engineering: Foundations, Principles and Techniques. Springer, Heidelberg (2005) 16. Spencer, H., Collyer, G.: #ifdef Considered Harmful, or Portability Experience with C News. In: Summer 1992 USENIX Conference (1992) 17. Svahnberg, M., Gurp, J., Bosch, J.: A Taxonomy of Variability Realization Techniques. Software: Practice and Experience 35(8) (2005)
Experience Report on Using a Domain Model-Based Extractive Approach to Software Product Line Asset Development* Hyesun Lee1, Hyunsik Choi1, Kyo C. Kang1, Dohyung Kim2, and Zino Lee2 1
Computer Science and Engineering Department Pohang University of Science and Technology (POSTECH), Pohang Korea {compial,nllbut,kck}@postech.ac.kr 2 Alticast Corp. Hana Capital Bldg., Seocho-dong, Seocho-gui, Seoul, Korea {dynaxis,zino}@alticast.com
Abstract. When we attempted to introduce an extractive approach to a company, we were faced with a challenging project situation where legacy applications did not have many commonalities among their implementations as they were developed independently by different teams without sharing a common code base. Although there were not many structural similarities, we expected to find similarities if we view them from the domain model perspective as they were in the same domain and were developed with the object-oriented paradigm. Therefore, we decided to place the domain model at the center of extraction and reengineering, thus developing a domain model-based extractive method. The method has been successfully applied to introduce software product line to a set-top box manufacturing company. Keywords: product line engineering, component extraction, domain model, feature model.
1 Introduction The extractive approach to product line engineering (PLE) capitalizes on existing systems to initiate a product line [1]. It can provide an efficient way for an organization to transform from traditional development to product line-based development without a large upfront investment. There have been few research efforts reported on the extractive approach, however. There are tools [2], [3] on the market, but their technical details are not known through publication. There are publications on reengineering and refactoring [4], [5] but most of these are not in the context of PLE. The extractive approach that we introduced to Alticast, Corp. presented us interesting research challenges. Since its founding in 1999, Alticast, Corp. has been marketing several types of digital set-top boxes1. Because of the diversity of markets and *
This research was supported by Korea SW Industry Promotion Agency (KIPA) under the program of Software Engineering Technologies Development and Expects Education. 1 A set-top box is a device that is connected to a television and digital network to restore the original signals from a video server to a displayable hardware, i.e., TV. S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 137–149, 2009. © Springer-Verlag Berlin Heidelberg 2009
138
H. Lee et al.
different types of set-top box products, development and maintenance of software systems has been extremely costly for the company. To address these problems, we introduced PLE to the company targeting on the set-top box domain. Alticast, Corp. already had a number of legacy set-top box products that have been sold in the marketplace. Therefore, for an efficient transition to product line-based development, we adopted an extractive approach. We targeted our project to the middleware and Electronic Program Guide (EPG) subsystems of the product line. EPG was a quite interesting product line as it provided us difficult research challenges. Due to the time-to-market pressure, frequent releases with new features, and the diversity of markets, the development of EPG products was done in parallel by separate teams without code cloning or sharing common assets even though the products shared a large number of common features. When we analyzed the code, each application had its own naming and design styles that were quite different from others, and use of tools to compare similarities was difficult. It was difficult to extract and reuse code without a considerable amount of laborious manual efforts. To address this problem, we developed a domain modelbased component extraction approach to PLE. Section 2 introduces the underlying concepts of our method. Overall processes and detail steps of our method are discussed in section 3. As an illustrative example, the EPG product line is used. Section 4 explains the application engineering process to validate the developed assets, and section 5 introduces the related work and compares them with our method. Section 6 concludes this paper with a summary of this project and future works.
2 Rationales behind Our Approach In this section, we discuss the rationales behind our method. We first explain the problem and technical challenges we had, and then explain our approach to address those challenges. We attempted to introduce a product line to Alticast, Corp. by extracting and reusing reusable components from three legacy products. When we analyzed the legacy products, however, we were immediately faced with a very difficult problem: The products had been developed independently by different development teams, each having its own naming convention and design structure. On the surface, it was difficult to see commonalties, and finding reusable components from the legacy systems was a very difficult challenge. Despite the problem we had, we expected to see some common design elements as all products share largely the same functionality. To compare and evaluate the functional commonalities, we needed to go beyond what we could find out on the surface through syntactic name comparison. We needed to find the functions each class, method or component implemented, and then compare these across different design models. In order to perform this systematically, we: (1) defined a domain model (domain object model) of the product domain that, we believed, represented the domain most appropriately, and (2) compared each design model against the domain model (not against each other).
Experience Report on Using a Domain Model-Based Extractive Approach
139
This domain model-based extractive approach had the following advantages: y Although each design model has partition of components and classes that are different from others, we can compare them through the intermediation of the domain model, and find a design model that most closely embodies domain concepts. y In addition, the number of comparisons we have to make can be reduced substantially, from n(n - 1)/2 to n comparisons for n products. After comparing and analyzing legacy products, we need to select a reusable architecture(s) and components from the products, and then reengineer them if necessary for the product line. As applications of the product line share the product line architecture and components, we must design them based on the domain concepts that are common across all products. Therefore, we decided to extract design elements (classes, components) that are most close to the domain model. To do this, we evaluated design models in terms of coverage and conformance. y Coverage measures the extent to which domain concepts (represented as domain entities and associations between entities in the domain model) are covered by a design model or a component. y Conformance measures the degree to which design elements (classes or components) of a design model realize closely related domain concepts. Each design element should implement a cohesive set of domain concepts. Details of these metrics are discussed in section 3.3. Based on these ideas, the method processes were defined, which are outlined and explained in the following section.
3 Engineering Process We define a method consisting of four engineering processes: recovering design models from existing products; analyzing the domain and creating a product line domain model; selecting reuse candidates that are “most appropriate” (discussed in section 3.3.) for reuse for the product line; and reengineering those reusable candidates to create the product line asset components (Fig. 1). Details of the processes and artifacts from each of these processes are discussed in the following subsections.
Fig. 1. Engineering process
140
H. Lee et al.
3.1 Design Recovery We want to reuse legacy software as much as economically viable in the development of product line assets. For this to happen, we need to recover and/or create design models, and collect necessary information for asset development. In this process we recover architectures, components, and class models from the legacy applications. We used a commercial UML CASE tool, Enterprise Architecture [6], to recover class models and components (as packages). Architectures were recovered manually. 3.2 Domain Analysis In this process we decide the product line domain boundary that covers all instances of legacy applications we have and possible future products in the product plan, and then create a feature model [7] and a product line domain model. For the product line, we need to create asset components with embedded variation points that can be instantiated for each product in the product line with appropriate variants. Each product of a product line may have a different coverage of the domain. To support domain model-based development of product line assets, we create a domain model that covers all products in the product line but with embedded variation points and variants for adaptation to specific products. We refer to this domain model as the product line domain model (PLDM). The personal video recorder (PVR) feature in Fig. 2 records broadcasting to the hard disk that we can play back, and Tuner is an operating environment feature and can be either Single Tuner or Multi Tuner. In Fig. 3, “<<●PVR>> Recorded Item” indicates that Recorded Item is related entirely to the optional feature PVR; “<< Multi Tuner>> quantity” represents that the attribute ‘quantity’ is related to the alternative feature Multi Tuner, and if we select or unselect Multi Tuner, the value of ‘quantity’ changes.
△
Fig. 2. Feature model of the EPG product line
With domain experts, we create a domain model by capturing entities in the domain boundary, as typically done in object-oriented development; create a feature model (Fig. 2) by capturing commonalities and variabilities among existing and planned products; and refine the domain model by embedding variation points and variants to create a PLDM (Fig. 3) using the feature model. Creation of these models is an iterative incremental process continuously comparing one model with the other,
Experience Report on Using a Domain Model-Based Extractive Approach 1 Watc hes
User
1 <<●PVR>> Rec ords
1
1..*
<>viewType
<<●PVR>> Plays 1
0..*
0..1
1
Plays-reserved- program- by 1
0..*
<<●PVR>> Recorded Item
Reserves
Window
141
programID recordedTime recordedData
0..1 1 <<●PVR, ●Rec ordingReservation>> Reserved- rec ords 0..*
Reservation <>reservationType 1 programID reservedTime 1 1..* Chec ks- for-use Requires 1
Tuner <<
Multi Tuner>>quantity
1<<●PVR>> Uses- for-rec ord
Fig. 3. PLDM of the EPG domain
especially focusing on maintaining consistency of variabilities between the two models. Availability of domain and marketing experts is most critical in this process. In this project, we spent about a month to create the feature model and PLDM of EPG domain with domain and marketing experts. The PLDM is used in the next section to evaluate design models of each legacy application of the product line. 3.3 Design Evaluation and Selection In this process we compare and evaluate design models with the PLDM and identify reuse candidates. It consists of three activities: model comparison, design evaluation, and reuse candidates selection. 1) Model Comparison: In this activity, we compare each design model with PLDM and construct a mapping table. As the capability of most tools for comparing models is limited to the syntactic level, we have to perform both automatic and manual comparisons. We employed the following strategies in the comparison: y Perform a structural comparison between a design model and PLDM. We want to find out how close each design structure is to that of PLDM. We believe that the closer the structure of a design model is to that of PLDM, it is more likely that the design model closely embodies the domain concepts and is more reusable than otherwise. y Compare attributes of classes of each design model with those of PLDM. We want to understand functional cohesiveness of the components and classes of each design. Again, we believe a design model that is more cohesive than others is more likely to be reusable as closely related concepts are “packaged” together. Entities, attributes, and associations of PLDM are compared with the corresponding components, classes, attributes, and methods of each design model. We compared PLDM with the three design models of the EPG products (Table 1). For example, an attribute reservationType defined for the Reservation entity of PLDM is defined as
142
H. Lee et al.
reserveType in the design model 1 (Design1) but there were no corresponding attributes in Design2 and Design3. These results are used as important information for evaluating and selecting reuse candidates from the legacy software in the activities that follow. 2) Design Evaluation: Reuse candidates are reengineered (if necessary) and used in the product line construction, thus identifying proper reuse candidates is important. In this activity, we evaluate design models to find the reuse candidates. We evaluate design models at three levels: conceptual, architecture, and implementation level. A. Conceptual Level At the conceptual level, as discussed in section 2, we evaluate the coverage and conformance of a design model to measure the conceptual affinity between the domain model and the design model. Table 1. PLDM-design model mapping table Product Line Domain Model Entity
Design1
Attribute Component
Association
Component
Design2
Design3
Class
Attribute /method
Component
Class
Attribute Component /method
Class
Attribute /method
Class
Attribute /method
Component
Class
Attribute/ Component method
Class
Attribute /method
A.1) Coverage: We measure the coverage of each design model and component using the comparison results (Table 1) and counting the components, classes, and associations of a design model that correspond to entities and associations of the PLDM. We first identify the set of covered domain concepts CC, and the set of covered domain attributes CA for each design model or a component. For example, CC(Design1) = {Reservation, RecordedItem, Tuner, Purchase(User-Program)}; CA(Design1) = {reservationType, programID(in Reservation), programID(in RecordedItem), quantity}; CC(Design2) = {Reservation, Purchase(User-Program)}; and CA(Design2) = {programID} (Table 1). The algorithm used is as follows: Let T be a mapping table; DC be a set of domain concepts (domain entities and associations) of a domain model; dci be a domain concept in DC; A(dci) be a set of attributes of dci ( if dci is an association); and X be a design model or a component to be evaluated. For a conceptual element (i.e., an entity, association, or attribute), y, of a domain model, the correspondence of y to X is given by
. The set of domain concepts covered by X, CC(X), and the set of domain attributes covered by X, CA(X), are given by
.
Experience Report on Using a Domain Model-Based Extractive Approach
143
To measure the coverage of design concepts by a design model or a component, we used the metric COV using CC and CA. The algorithm used is as follows: For dci, the ratio of domain attributes covered by X, ra(dci, X) is given by
. The coverage of domain concepts by X, COV(X) is given by .
For the example given in Table 1, COV(Design1) = 1, and COV(Design2),and COV(Design3) = 0.375. COV of the design models of three EPG products were 0.83, 0.73, and 0.66, respectively. We can also measure coverage for classes in the same manner. A.2) Conformance: For high quality assets, cohesive responsibilities must be allocated together to design entities. We can expect that, if a design model is consistent with the domain model, the design classes of the design model will most likely be cohesive. Therefore, for each component in a design model, we check conformance at the entity (component, class) level by comparing allocated attributes and methods. We measured the conformance of each component using the sets CC and CA. To measure conformance of each design entity (a component or a class) Z in a design model X, we used the following procedure:
∈
y For each domain concept dci CC(Z), count the number of entities in the design model X that collectively cover dci. If there are “many” entities covering dci, we consider that Z has a lower conformance to dci than otherwise because dci is scattered to “many” design entities. y For each pair of domain concepts, (dcj, dck) CC(Z), identify the closeness between dcj and dck. If they are not connected each other though associations, Z has a lower conformance than otherwise because Z realizes unrelated domain concepts together.
∈
B. Architecture Level We must reuse an appropriate architecture(s) for the product line. To identify a candidate architecture(s) for reuse, we need to evaluate architectural quality attributes. In this project, we used the Architecture Tradeoff Analysis Method® (ATAM®) [8]. One quality attribute that is not directly addressed by ATAM but is very important in the product line approach is adaptability. (Maintainability encompasses adaptability. However, we did not see the need to generate detailed scenarios as we had a good understanding of variability through feature modeling.) We used the feature model to identify variable features and evaluate how easily each design model can accommodate the variability. C. Implementation Level For reuse of components, the quality of implementation is important. At the implementation level, we evaluate the quality of the implemented code using various code
144
H. Lee et al.
Table 2. Quality attribute evaluation results of the EPG design models by using IBM Rational Software Analyzer® Evaluation Metric2 CohesionS CouplingV UnderstandabilityS
LCOM1V LCOM2V CCV MIS ANOCOMS ABDV
Design1 Design2 Design3 2.00 0.77 3.08 231.2 118.0 1.80
3.00 0.89 3.39 204.68 73.43 1.88
2.00 0.80 2.53 217.27 81.0 1.69
S: The higher, the better, V: The lower, the better
analysis metrics such as complexity, cohesion, inheritance, and dependency. We used a commercial tool, IBM Rational Software AnalyzerⓇ [9]. Design1 had a higher cohesion and a lower coupling value, and was more understandable than others (Table 2). (Details of analysis results are discussed in section 6.) 3) Reuse Candidates Selection: Considering the evaluation results together from the previous activity, we select an architecture(s) and components that are most suitable for reuse in asset development. We employed the following strategy in the selection: y The candidate design model should have a higher coverage (higher COV value) than others. y The candidate components should have a higher conformance than other comparable components. y The candidate architecture should satisfy the important quality attributes represented in the feature model. y The implementation of the candidate design model or component should have better code quality than other design models or components that have same responsibilities. If we can select an architecture and a large portion (more than 70%) of candidate components and classes from a certain design model, the design model is called the “base design model.” If we have a base design model, we may lower the ‘adoption barriers [1]’ as we have developers familiar with the design. Reengineering of the selected candidates is discussed in the section 3.4. 3.4 Product Line Reengineering The purpose of this process is to create a product line design model (PLdeM, i.e., asset architecture(s), components, and classes with embedded variation points),and implement it using reuse candidates, PLDM, and the feature model created in the earlier activities (Fig. 1). This process consists of three activities: architecture 2
LCOM1 (Lack of Cohesion of Methods 1), LCOM2 (Lack of Cohesion of Methods 2), CC (Cyclomatic Complexity), MI (Maintainability Index), ANOCOM (Average Number of Comments Metric), and ABD(Average Block Depth)
Experience Report on Using a Domain Model-Based Extractive Approach
145
modification; component modification; and implementation with embedded variabilities (i.e., variation points and variants). 1) Architecture Modification: The first task is to create the architecture for PLdeM that satisfies the quality attributes represented in the feature model and is adaptable for products in the product line. We can modify the candidate architecture, or create a new one if modification of the candidate architecture requires an excessive effort. To assess and improve the architecture, we can use ATAM [8] and Attribute Driven Architecture Design (ADD) [10] in addition to design patterns and tactics [11]. 2) Component Modification: Based on the architecture, we modify the reuse candidate components, if necessary. Some components may be reused without modification, but to satisfy the required quality attributes and/or the functional requirements, other components might need to be modified. While modifying them, we continue to evaluate the quality attributes and any improvement actions that can happen in refactoring can also happen here. 3) Implementation with Embedded Variabilities: To meet the variability requirements of the product line, we must insert variation points into component implementations. We can use several implementation techniques such as templates, dynamic binding, option tables, and macro processing. The candidate architecture from Design1 implemented the Program Purchase functionality inside EPG Controller component. To improve reliability and maintainability, we decided to separate the functionality from EPG controller to a new component. Also, we reused the Purchase Manager component from Design2 and allocated the Program Purchase responsibility to it (Fig. 4). We used a macro language (e.g., $IF(;$RecordingReservation[…]) in Fig. 5) in addition to mechanisms, such as inheritance and templates, that come with the programming language.
Fig. 4. Product line design model of the EPG domain
146
H. Lee et al. In ProgramReservation Component: Class ReservedProgram <;$RecordingReservation> { … restoreFromPref (str String){ $IF(;$RecordingReservation)[ If( reserveType==“RecordingReservation”) strBuf.append(reserveType).append(DELIMITER); … ]…
Fig. 5. A part of implementation of the EPG application
4 Application Engineering for Asset Validation To validate the reengineered assets, we developed two EPG applications running in different set-top boxes. One was a low-end set-top box providing only basic tuning and viewing features, while the other was a high-end set-top box supporting PVR-related features such as Recording Reservation, Play Control, and Multi Tuner (Fig. 2). We performed the following application engineering procedures to develop these EPG applications and to check if the asset-based products work correctly in the product line environment. 1) Feature Selection. We used the ASADAL CASE tool [12] to build an EPG feature model during the product line reverse engineering, and also to select features for each EPG application during application development. The tool made feature selection easy by automatically applying feature dependency rules (“require” and “exclude” relationships), preventing selection conflicts. We selected all PVR-related features for the high-end set-top box, whereas only mandatory and a small number of alternative features for the low-end one. The ASADAL tool generated information on the selected features in an XML file, which was used for asset adaptation. 2) Asset Adaptation. We generated source code of each EPG application from the reengineered assets by processing variation points in macros and inserting variants that correspond to the selected features specified in the XML file. A variant might be a component, a class, or a code segment. 3) Code Generation. We compiled the generated source code of each EPG application, and linked it with other set-top box software modules and some libraries encapsulating set-top box devices. The resulting file was an executable image for the set-top box. 4) Application Test. We uploaded each executable image onto the corresponding set-top box, connected the box to cable television networks, and checked whether the box provided the selected features correctly. We tested some features manually and the others with automatic test suites. Both the low-end and the high-end settop boxes operated correctly, and we could conclude that those reengineered assets related to basic tuning, watching, and PVR features were validated. We were also able to generate all three EPG applications (Design1, Design2, and Design3 in Table 1) that we used to create product line assets. Although the structure of generated source code was different from that of the original one, their functional-
Experience Report on Using a Domain Model-Based Extractive Approach
147
ities were the same. Also, there was no visible performance difference between the asset-based products and the original ones.
5 Related Work There have been active researches in the reengineering and refactoring fields [4], [5]. Although many researchers have focused on reusing legacy systems to reduce development cost and effort, there have been a few methods extending the techniques to software product line engineering. J. DeBaud et al. [13] introduced a reengineering method using a domain model. Although their method was not in the product line context, they emphasized the importance of a domain model. They used a domain model to define and understand the context of a program, but we create a domain model to define the context of a family of programs, to extract and reengineer components from legacy software, and to create a product line. With the emergence of the software product line paradigm, researchers have performed research on reengineering in the context of product line engineering. J. Bayer et al. [14] presented the ‘RE-PLACE’ framework to support transition of existing software assets to a product line architecture. They performed asset reengineering, product line design, and architecture modeling by extracting features. R. Kolb et al. [15] introduced PuLSE™-DSSA process and applied it to reengineer an image memory handler component to reuse it in a software product line. Although both researchers introduced reengineering for asset components development, they did not analyze and manage commonalities and variabilities of the domain model in a systematic way. We believe that a domain model-based approach can easily build good software quality attributes into product line assets. Since the feature oriented domain analysis [7] was introduced, some researchers performed reengineering and refactoring from the feature-oriented perspective. K.C. Kang et al. [16] reengineered legacy home service robot applications into product line assets using a feature-oriented method [17]. J. Liu et al. [18] introduced the feature oriented refactoring (FOR) process which decomposes a system into features and reengineered the system based on the features. They reengineered an open source data base system implemented in Java using the FOR process. Although these researchers performed reengineering in terms of features, they did not consider extracting code components from a family of legacy applications for use in creating an asset base for a product line. Their methods are not in the context of an extractive approach. V. Alves et al. [19] created a mobile games product line in an extractive approach. They introduced a method for extracting and evolving a product line using the aspectoriented method. Although they extracted product lines with simple refactoring laws, they assumed a high level of design similarities among products. Thus, if there are few structural similarities, the method is difficult to apply. Our method of inserting variabilities into a domain model based on a feature model is somewhat related to research in the model transformation field. K. Czarnecki et al. [20] introduced a template-based approach for mapping a feature model to activity diagrams. F. Heidenreich et al. [21] presented ‘FeatureMapper’ which is a tool to define mappings of features to model elements by specifying feature realizations.
148
H. Lee et al.
Unlike their focus on model-based transformation, we focus on the model-based component extraction from a family of related systems.
6 Conclusion and Future Work In this project, we have shown how a domain model can play a key role in an extractive PLE approach. By analyzing design models of different systems using a domain model, we could easily find commonalities among the designs of a family of related systems. Moreover, by selecting reuse candidates that are similar to the domain model, effective reengineering became possible. Some of the interesting findings we have from this project are: y Effectiveness of Domain Model-Based Approach: Through domain modeling, we could have a clear understanding of the domain and also what to look for from a design model. Without this, comparing a design model with others was like comparing an apple with an orange. However, there is an extra cost for developing these models. We spent about a month to do domain modeling. y Base Design Model: In section 3.3 we discussed base design model. If we have a base design model, we can transition from product-based development to product line-based development more efficiently as we can reuse the design itself, which implies that we can also reuse many of the components included in the design. In our project, Design1 was the base design model we selected, and the architecture and most of the components of Design1 were used. y Conformance at the Conceptual Level and Quality Attributes at the Implementation Level: We found some interesting correlations between the level of conformance of a design model and the quality of implemented code. A design model that had high conformance at the conceptual level had high quality assessments at the implementation level. When we evaluated quality attributes of three design models using the tool, Design1 (which had the best conformance value) turned out to have the best quality values (Table 2). A good design lends itself to a quality implementation. Feasibility of our method was demonstrated in the EPG domain. To quantitatively analyze the effectiveness of this method, we plan to continuously monitor how much time and efforts are required to develop applications from the product line assets, and how well these applications meet functional and quality requirements. In the project, we could select one design model as the base design model and reuse the architecture and components of that design model. However, there can be situations where we need to create a new product line architecture and reuse components from several legacy products. We plan to explore other project situations and improve our method.
References 1. Krueger, C.W.: Easing the Transition to Software Mass Customization. In: Proc. of the 4th International Workshop on Product Family Engineering, October 2001, pp. 282–293 (2001) 2. GEARS, BigLever Software, Inc., http://www.biglever.com/
Experience Report on Using a Domain Model-Based Extractive Approach
149
3. Pure:Variants, Pure-systems, Inc., http://www.pure-systems.com/ 4. Fanta, R., Rajlich, V.: Reengineering Object-Oriented Code. In: Proc. of ICSM, November 1998, pp. 238–246 (1998) 5. Tahvildari, L., et al.: Quality-Driven Software Re-Engineering. J. Systems and Software 66(3), 225–239 (2003) 6. Enterprise Architecture, Sparx systems, Inc., http://www.sparxsystems.com/products/ea/ 7. Kang, K.C., et al.: Feature Oriented Domain Analysis (FODA) Feasibility Study. CMU/SEI-90-TR-21, SEI, CMU (November 1990) 8. Kazman, R., et al.: ATAM: Method for Architecture Evaluation. CMU/SEI-2000-TR-004, SEI, CMU (August 2000) 9. Rational Software Analyzer, IBM,Inc., http://www.ibm.com/software/awdtools/swanalyzer/ 10. Wojcik, R., et al.: Attribute-Driven Design (ADD), Version 2.0. CMU/SEI-2006-TR-023, SEI, CMU (November 2006) 11. Bachmann, F., et al.: Illuminating the Fundamental Contributors to Software Architecture Quality. CMU/SEI-2002-TR-025, SEI, CMU (August 2002) 12. Kim, K., et al.: ASADAL: A Tool System for Co-Development of Software and Test Environment Based on Product Line Engineering. In: Proc. of the 28th ICSE, May 2006, pp. 780–786 (2006) 13. DeBaud, J., Rugaber, S.: A Software Re-engineering Method Using Domain Models. In: Proc. of the ICSM, pp. 204–213 (1995) 14. Bayer, J., et al.: Transitioning Legacy Assets to a Product Line Architecture. In: Proc. of ESEC/FSE, September 1999, pp. 446–463 (1999) 15. Kolb, R., et al.: A Case Study in Refactoring a Legacy Component for Reuse in a Product Line. In: Proc. of the 21st ICSM, September 2005, pp. 369–378 (2005) 16. Kang, K.C., et al.: Feature-Oriented Re-engineering of Legacy Systems into Product Line Assets – a Case Study. In: Proc. of the 9th SPLC, September 2005, pp. 45–56 (2005) 17. Kang, K.C., et al.: Feature Oriented Product Line Engineering. IEEE Software 19(4), 58– 65 (2002) 18. Liu, J., et al.: Feature Oriented Refactoring of Legacy Applications. In: Proc. of the 28th ICSE, May 2006, pp. 112–121 (2006) 19. Alves, V., et al.: Extracting and Evolving Mobile Games Product Lines. In: Proc. of the 9th SPLC, September 2005, pp. 70–81 (2005) 20. Czarnecki, K., Antkiewicz, M.: Mapping Features to Models: A Template Approach Based on Superimposed Variants. In: Proc. of the 4th International Conference on Generative Programming and Component Engineering, September-October 2005, pp. 422–437 (2005) 21. Heidenreich, F., Kopcsek, J., Wende, C.: FeatureMapper: Mapping Features to Models. In: Proc. of the 30th ICSE, May 2008, pp. 943–944 (2008)
Reuse with Software Components – A Survey of Industrial State of Practice Rikard Land1, Daniel Sundmark1, Frank Lüders1, Iva Krasteva2, and Adnan Causevic1 1
Mälardalen University, School of Innovation, Design and Engineering, Västerås, Sweden 2 Faculty of Mathematics and Informatics, Sofia University, Sofia, Bulgaria {rikard.land,daniel.sundmark,frank.luders, adnan.causevic}@mdh.se, [email protected]
Abstract. Software is often built from pre-existing, reusable components, but there is a lack of knowledge regarding how efficient this is in practice. In this paper we therefore present qualitative results from an industrial survey on current practices and preferences, highlighting differences and similarities between development with reusable components, development without reusable components, and development of components for reuse. Component reuse does happen, but the findings are still partly disappointing: currently, many potential benefits are not achieved. Still, the findings are encouraging: there are indeed good, reusable components properly verified and documented, and mature organizations who manage to reuse these components efficiently, e.g. by leveraging the previous component verification. We also find that replacing one component for another is not necessarily complicated and costly.
1 Introduction The paradigm of component-based software engineering (CBSE) has a number of perceived benefits [1] [2]: components may be developed independently of each other and interact only through explicit interfaces, which open up the possibility for component reuse in new contexts. It provides a framework for defining architectures and facilitating ease of integration, when using pre-existing components as well as in a top-down design decomposition system development [3]. By selecting pre-existing components that have been proven in use and enhanced over time, it would be possible to construct high quality systems more rapidly than ever. Moreover, research is progressing towards the vision that system behaviour can be predicted from component behaviour [4] [5], which would make reuse even more attractive, as the consequences of selecting a particular component would be known in advance. However, in practice, software reuse through components is difficult and not entirely successful, for several reasons: first, components do not always live up to the expectations, partly because it is inherently extremely difficult to verify a component without a context. Second, it is seldom easy to exchange a component for another; even though (part of) the interface is identical or similar. Thus, at least some of the development time saved through reusing a component needs to be spent in the S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp.150–159, 2009. © Springer-Verlag Berlin Heidelberg 2009
Reuse with Software Components
151
selection, evaluation, and verification of components, and explicit management of the relationships with component vendors. This typically also leads to vendor lock-in, and reuse is thus often degraded to only an initial event in a system’s history. We set out to study the state of the practice in the following general software development activities, from a software component reuse perspective: requirements elicitation and customer interaction, design and implementation, verification, and component selection and evaluation. For this purpose, we constructed a web-based survey and invited organizations reusing and integrating existing software components, as well as organizations not reusing components, and component builders, as respondents. Focus was on the technical staff (developers, testers, architects, etc.) This paper presents the results of this survey, thereby providing an insight in how well CBSE supports software reuse in current practice, how and to what extent components are verified in isolation, and how component users test and evaluate components before selecting them. There are two main research questions reflected in the structure of this paper: first, in Section 4, we investigate whether there are any differences in how development activities are performed, depending on whether software development include the reuse of components or not. Developers of components for reuse are included as a third group in this comparison. Then, in Section 5, we investigate how component selection and evaluation, is performed by projects developing software (partially) by integrating reusable components. First however, in Section 2 we describe the background, and in Section 3 we present the research method used to perform and analyse the survey. Section 6 concludes the paper and presents ideas on future work.
2 Background and Related Work Although software reuse has some potential benefits, practice has shown a great many challenges, and not only technical aspects must be mastered. Any serious software reuse attempt must permeate the organization and allow existing processes and practices to be modified [6]. Other empirical studies of software reuse have been conducted (see e.g. [7] for a review) and even some focusing specifically on reuse with components [8] [9]. The study presented here adds to this body of work by investigating some specific questions, in particular related to verification and component selection. Other related work is referred to in context throughout the rest of the paper: Section 4 describes existing approaches to requirements and customer interaction [10] [11], design and implementation [11] [12], and verification [3] [13] [14], which has a bearing on component reuse. Section 5 relates to literature with suggested methods for Off-the-Shelf (OTS) component selection and evaluation [15] [16] [12] [17] [18] [19] [20] [21] [22]. In these sections, we describe suggested methods, practices, and previous observations found in literature, and relate our empirical survey results with them, to investigate the extent to which suggested guidelines etc. are adopted in practice.
152
R. Land et al.
3 Research Method To study how the component-based software paradigm support reuse in practice, we constructed a web-based questionnaire. Invitation emails were sent to companies that were part of our joint research projects such as FLEXI1 and NESSI2 , among others. We thus received a total of 93 responses, 30 of which seem to have quit the questionnaire after providing only some background information. We believe the main reason is that they perceived the questionnaire would take too long time, and we cannot know if this poses a particular threat to validity, i.e. if some particular types of answers were thus systematically excluded. However, since the respondents are anonymous we cannot know how many organizations these represent. Also, as we sent the invitation to participate to some email lists, and encouraged every recipient to further spread the invitation we can neither know the response frequency, nor exactly which organizations are represented. Hence, during any statistical treatment of the data we must bear in mind the limitations imposed by this type of convenience sampling to the external validity of the results. More information about the questionnaire, as well as all data, is available as a technical report [23]. In much of our analysis, we explore any differences between development with reusable components, development without reusable components, and development of components for reuse. These three groups are defined as illustrated in Fig. 1, based on three specific questions in the questionnaire: we consider two complementary subsets of development projects: with or without reusable components. Orthogonal to this division, we also consider projects developing components for reuse (which we study, as indicated in the figure), and projects developing (non-reusable) products and systems used by end users.
Fig. 1. Groups of respondents
For each respondent, based on the responses to some mandatory initial questions in the questionnaire, some later sections of questions were shown or hidden. As this caused the number of respondents to vary between sections, the number of respondents in each survey section is specified in Table 1, both per group and the total 1 2
http://www.flexi-itea2.org/ http://www.nessi-europe.com/
Reuse with Software Components
153
(which is the sum of the first two columns, i.e. the groups representing development with and without reusable components). Table 1. Number of responses in each respondent group for each section in the survey Development... Survey Section Agile practice preferences Testing Component development System development with reusable components System development
...with reusable ...without reuscomponents able components 32 18 24 12 8 5 29 0
...of components for reuse 8 6 8 5
50 36 13 29
25
6
25
0
Total
4 Development with, without, and for Reuse In this section, we analyze the activities requirements elicitation and customer interaction, design and implementation, and verification. In particular, we explore the differences, if any, between development with reusable components, development without reusable components, and component development for reuse. 4.1 Requirements Elicitation and Customer Interaction Interaction with customers and feedback [11] affect how requirements are formulated, how fixed they are, and how often deliveries are made. Generally, our results show that regardless of the level of component reuse in development, incremental delivery is a widespread practice, but requirement handling and collection of customer feedback varies between development of, with, and without reusable components. Regular interaction. For development without reuse, regular interaction between developers and customers/business people is in general encouraged by management, while for development with and for reuse, there is no consensus. However, there is a consensus among the respondents that they would like such regular interaction to be increased. Changing requirements. For development with reusable components, there is a slight tendency to discourage customers from changing requirements once they are specified. For development without reusable components, the tendency is the opposite: customers have more possibilities to change their requirements. A possible explanation is that when a decision has been made to use a reusable component, requirement changes may have a larger impact on the existing design [10] [12]. However, both groups seem to be dissatisfied with the current state: respondents in the development with reusable components group would like to allow their customers to change their requirements, while respondents in the development without reusable components think customers should be allowed to change less. For the above questions, the development of components for reuse group provides answers without any clear preferences.
154
R. Land et al.
Incremental delivery. In all groups, the general practice is to deliver software to customers incrementally, and all respondents think this practice should be even more emphasized. All groups in general also provide users with early versions (alpha/beta) of the software, but this tendency is stronger among system development than component development for reuse. One interpretation of this difference is that it more useful feedback can be collected from end users using an incomplete or buggy user interface application, than from component users using an unreliable component. Delivery of source code. Sometimes, the software is delivered as source code, and sometimes in binary format, without any particular tendency or any difference between the groups. This may indicate that the domain determines what is convenient, rather than for example different types of business relationships in the groups, or any difference in the desire to keep the implementation secret. Customer feedback. In development of systems for end users, the respondents almost uniformly state that end customer feedback is collected and evaluated through different mechanisms. This can be contrasted to development of components, where the respondents are more varied in their responses, but still with a slight overweight in support for this practice. One partial interpretation is that for at least reusable components developed for the mass-market, the distance to customers is large (although this distance can be decreased: we are aware of one COTS vendor which presents the current state to their key customers in web conferences every second week, and allow interaction in these virtual meetings). 4.2 Design and Implementation This section reports on some findings related to design and implementation from the perspective of the three groups defined above. Our findings point out that incremental design and coding is a preferred practice among the respondents, but also that there are differences between the preferred and the actual practice. Interleaving of design and programming. The responses are very varied as to what degree programming should be allowed to start before design is completed. The current practice varies across the scale for all groups of respondents, although those doing development without reuse has a slight tendency towards being more permissive of starting programming early. When asked about their preference, all three groups are less permissive when compared to the current practice, although this is not the case for each individual respondent. Incremental design and coding. This is often viewed as a good way to discover design problems early and to get early customer feedback [11]. Our findings show that it is widely used in current practice, independently of whether development is done with, without or for reuse. When asked about their preference, the respondents unanimously agreed that the incremental approach is desirable. Return on investment of designing components for maintainability. The group of respondents representing development of software components for reuse unanimously agreed that if enough efforts for building a good and maintainable design of a component are not spent in advance, the cost of change for a component is really high. Respondents outside this group were not asked this question.
Reuse with Software Components
155
Redesigning component-based systems. Design lock-in has been identified as a potential side-effect of building systems from pre-existing software components [12]. However, the majority of respondents agreed that redesigning a system is not a big issue when building a system out of components. The group representing development without software components were not asked this question. 4.3 Verification Ease of verification is one of the main arguments for software reuse through components [3] [14]. The main idea is that components that have been verified in previous settings and deployments will not require as much verification effort as software developed from scratch. Such savings would be highly relevant, since verification is widely known to consume significant portions of the resources in software development projects [13]. In this section, we investigate system and component verification from the perspective of current practice in software development with, without and for reuse. General opinions. Regardless whether the system is built with or without reusable components, most respondents find themselves having less time for testing than they would like to. Looking at the ideal verification practices, in the eyes of the respondents, unit testing still has a high degree of preference. Moreover, respondents generally feel that both functional black-box testing and testing based on code analysis should be increased compared to current practice, and functional black-box testing is preferred over testing based on code analysis. Unit testing and component testing. In system development with and without reuse, most respondents report a high level of use of unit testing. The same goes for functional black-box testing of components. This trend is even more apparent when looking at functional black-box testing on system-level. Answers are similar for performance and security testing, but we feel that these types of testing are too domain-specific to consider generally. In component development for reuse, both functional black-box testing and testing based on code analysis (e.g. statement or path coverage) are present in some projects. For all these verification methods, there is a noticeable difference between the current practice and the perceived ideal level of usage, which in general is significantly higher. Integration testing. To a large extent, respondents find themselves in projects that allow code changes during integration testing. Interestingly, respondents developing systems with reusable components find this less problematic than those developing systems without reuse. In addition, the respondents do not consider it easier to test systems built out of reusable components which are previously tested in isolation, than to test systems built without reuse. Testing of documentation. In all groups, testing of documentation is something that is perceived to be largely neglected, and most respondents, except those developing components for reuse, would like a significant increase in this practice. However, out of the 8 developing components for reuse, only 2 explicitly agree that the documentation provided with the components is sufficient for the needs for the component users.
156
R. Land et al.
In-house vs. Subcontracted vs. OTS. Among the respondents, there are stronger explicit demands on the documentation and verification of subcontracted components compared to the documentation and verification of in-house or OTS components. Component creators and component users both think that the current state of documentation and verification fulfil the needs of component users, for subcontracted and OTS components, but not for in-house components. This is also reflected in a stronger dissatisfaction with the documentation and verification of in-house components, compared to that of subcontracted or OTS components. One possible explanation for this is that the distance from a subcontractor or OTS vendor to the component user is greater, and also that the amount (and quality) of documentation is regulated by contracts (for subcontractors), or implicitly required in order to have an attractive product (for OTS vendors). Whatever the reason, this points us in a direction where component reuse could be improved by providing more efficient and practically useful documentation.
5 Component Selection and Evaluation In this section, we describe the current state of practice concerning the selection of reusable components to use during software development, and the challenges of evaluating reusable components in a system context. 5.1 Component Selection The commonly suggested practice for OTS selection is to first filter away many component candidates in a high-level evaluation phase, based on information and documentation about the components, and only later perform a prototyping hands-on evaluation of a final few components by writing test cases and create prototypes [15] [16]. Roles involved in component selection. The survey responses indicate that in some projects, only the development unit is involved in the component evaluation and selection process, while other projects heavily involve customers or internal staff with a responsibility to know the market and customers. Although it is true that some components are not directly visible to customers and end users, more often than not, the decision to use a specific component does have a business impact; it may for example strongly affect the possibilities for future extensions of the systems [12] [17]. Thus, it appears that, in some companies, the current state of practice needs to be improved. Interleaving system requirements elicitation and component selection. The respondents tend to formulate requirements on components fully prior to evaluation and selection. However, they generally find it difficult to break down system requirements to component requirements. This indicates that many organizations have not yet implemented the practice [15] to interleave component selection with the requirements elicitation process, as suggested by e.g. the methods PORE (Procurement-Oriented Requirements Engineering) [18], CRE (COTS-Based Requirements Engineering) [19] and CARE (COTS-Aware Requirements Engineering) [20]. However, as said, the majority of the respondents assert that customers or business people are involved during component selection and evaluation. One interpretation is therefore that require-
Reuse with Software Components
157
ments elicitation and component selection and evaluation are often in practice interleaved, albeit not formalized as a process. 5.2 Component Evaluation Prototyping evaluation. After some initial, high-level evaluation, based on information about OTS components (or existing knowledge of the potential components) [8], the suggested practice is to create prototypes, or simulate the system’s usage of the component through testing [15]. There are two main goals for this: To examine technology or architecture [15] [16]; the survey results clearly show this type of prototyping activity is widely performed in practice. To evaluate component assemblies (rather than individual components) [15] [16] [21] [22]; the result varies with no clear tendency. Usage of provided test cases. Our responses vary concerning whether test cases provided with the components are used to evaluate them. The respondents who use test cases provided with the components report that they also develop their own test cases for components in order to evaluate them, and surprisingly, those that do not use test cases provided with the components do not write their own test cases. Even more surprising is perhaps that this is true not only for subcontracted or in-house developed components – where one could expect the detailed functionality, level of quality, and responsibility for quality assurance to be specified by contracts – but also for OTS components. Insufficient evaluation. High-level component evaluation and prototyping evaluation complement each other; however, if the components to select from are known, it may be sufficient to do a brief hands-on evaluation in the new context [8], which could partly explain that some of our respondents do not evaluate components prior to selection. However, some of the respondents who do not test their components believe testing is more efficient than documentation (this is true also for all respondents who do use test cases), which makes us lean towards the following conclusion: there are organizations and projects where OTS components are selected without proper evaluation – and that they are aware of this. However, there are also indeed organizations that perform systematic evaluation of OTS components.
6 Conclusion and Future Work This paper presented an empirical, qualitative study of reuse with software components. Our data indicate that reuse of components does not make design decisions as permanent as might be feared. The impact of requirements changes are inconclusive. Regarding verification, the general opinion in our study is that it is not done to a sufficient extent, independent of component reuse. Separate verification of reusable components in isolation does not in general make system verification or component evaluation easier. Known good practices for component selection and evaluation are implemented in some organizations but not all. In conclusion, as for the current state of the practice of component reuse in industry, we can claim that components are as a matter of fact built for reuse, and those components are in fact being reused. The main reasons (which we have not studied)
158
R. Land et al.
are probably those of cost and time for system development: through component reuse systems can be built cheaper and faster. However, some other potential benefits (which we have studied) are not in general experienced: in particular system verification is not necessarily made easier, and requirements engineering, and ultimately the ways system developers interact with their customer, need to change further than is the case in general today. Nevertheless, our study clearly shows that there are organizations where these benefits are indeed experienced, but this is apparently hard to achieve without explicit attention and effort. Further research includes studying the organizations which manages component reuse the best in order to identify good practices and how to implement them in different circumstances. Many such practices and potential benefits are already known, but are, according to our results, not yet widely adopted in industrial practice. As this generally confirms previous studies, it is useful as it adds to the body of knowledge and may provide additional insights.
Acknowledgements This work was partially supported by the Swedish Foundation for Strategic Research (SSF) via the strategic research centre PROGRESS, the Bulgarian Ministry of Education and Science, and FLEXI. Thanks also to all the questionnaire respondents and the people who have been involved in earlier phases of this research.
References 1. Szyperski, C.: Component Software, 2nd edn. Addison-Wesley, Reading (2002) 2. Wallnau, K., Hissam, S., Seacord, R.: Building Systems from Commercial Components. Addison-Wesley, Reading (2001) 3. Crnkovic, I., Chaudron, M., Larsson, S.: Component-based Development Process and Component Lifecycle. In: International Conference on Software Engineering Advances (ICSEA 2006), Tahiti (2006) 4. Hissam, S., Moreno, G., Stafford, J., Wallnau, K.: Packaging Predictable Assembly with Prediction-Enabled Component Technology, Pittsburgh (2001) 5. Land, R., Carlson, J., Larsson, S., Crnkovic, I.: Towards Guidelines for a Development Process for Component-Based Embedded Systems. In: Workshop on Software Engineering Processes and Applications (SEPA), Yongin, Korea. LNCS (2009) 6. Karlsson, E.-A.: Software Reuse: A Holistic Approach. John Wiley & Sons Ltd., Chichester (1995) 7. Mohagheghi, P., Conradi, R.: Quality, Productivity and Economic Benefits of Software Reuse: A Review of Industrial Studies. Journal of Empirical Software Engineering 12(5), 471-516 (2007) 8. Li, J., Torchiano, M., Conradi, R., Slyngstad, O., Bunse, C.: A State-of-the-Practice Survey of Off-the-Shelf Component-Based Development Processes. In: Morisio, M. (ed.) ICSR 2006. LNCS, vol. 4039, pp. 16–28. Springer, Heidelberg (2006) 9. Li, J., Conradi, R., Bunse, C., Torchiano, M., Slyngstad, O., Morisio, M.: Development with Off-The-Shelf Components: 10 Facts. IEEE Software 26(2), 80–87 (2009) 10. Cooper, K.: Can Agility be Introduced into Requirements Engineering for COTS Component Based Development? In: International Workshop on Software Product Management, IWSPM (2006)
Reuse with Software Components
159
11. Beck, K.: EXtreme Programming EXplained: Embrace Change. Addison Wesley, Reading (1999) 12. Krasteva, I., Branger, P., Land, R.: Challenges for Agile Development of COTS Components and COTS-Based Systems – A Theoretical Examination, Funchal, Portugal (2008) 13. Tassey, G.: The Economic Impacts of Inadequate Infrastructure for Software Testing (2002) 14. Aoyama, M.: New age of software development: How component-based software engineering changes the way of software development. In: Proceedings of International Workshop on Component-Based Software Engineering (1998) 15. Land, R., Blankers, L., Chaudron, M., Crnkovic, I.: COTS Selection Best Practices in Literature and in Industry. In: Mei, H. (ed.) ICSR 2008. LNCS, vol. 5030, pp. 100–111. Springer, Heidelberg (2008) 16. Oberndorf, P., Brownsword, L., Morris, E., Sledge, C.: In: Workshop on COTS-Based Systems (1997) 17. Krasteva, I., Land, R., Sajeev, A.: Being Agile when Developing Software Components and Component-Based Systems – Experiences from Industry. In: EuroSPI, Madrid, Spain (2009) 18. Maiden, N., Ncube, C.: Acquiring COTS Software Selection Requirements. IEEE Software 15(2) (1998) 19. Alves, C., Castro, J.: CRE: a systematic method for COTS components Selection. In: Proceedings of the XV Brazilian Symposium on Software Engineering (SBES), Rio de Janeiro (2001) 20. Chung, L., Cooper, K.: Defining Goals in a COTS-Aware Requirements Engineering Approach. Systems Engineering 7(1) (2004) 21. Burgués, X., Estay, C., Franch, X., Pastor, J., Quer, C.: Combined Selection of COTS Components. In: Dean, J., Gravel, A. (eds.) ICCBSS 2002. LNCS, vol. 2255, pp. 54–64. Springer, Heidelberg (2002) 22. Bhuta, J., Boehm, B.: A Method for Compatible COTS Component Selection. In: Franch, X., Port, D. (eds.) ICCBSS 2005. LNCS, vol. 3412, pp. 132–143. Springer, Heidelberg (2005) 23. Causevic, A., Krasteva, I., Land, R., Sajeev, A., Sundmark, D.: An Industrial Survey on Software Process Practices, Preferences and Methods (2009) 24. Land, R., Alvaro, A., Crnkovic, I.: Towards Efficient Software Component Evaluation: An Examination of Component Selection and Certification. In: Euromicro SEAA SPPI Track, Parma, Italy (2008)
Evaluating the Reusability of Product-Line Software Fault Tree Analysis Assets for a Safety-Critical System Josh Dehlinger1 and Robyn R. Lutz2 1
Department of Computer and Information Sciences, Towson University, 7800 York Road, Towson, Maryland, USA 21252 [email protected] 2 Department of Computer Science, Iowa State University, 226 Atanasoff Hall, Ames, Iowa, USA 50011 and Jet Propulsion Laboratory / Caltech [email protected]
Abstract. The reuse of product-line assets enables efficiencies in development time and cost. Safety analysis techniques for Software Product-Line Engineering (SPLE) construct safety-related, non-code artifacts with the aim of reusing these assets for new product-line members. In this paper we describe results from the construction and reuse of a key safety-analysis technique, Product-line Software Fault Tree Analysis (PL-SFTA), and its supporting tool, PLFaultCAT. The main contribution of this work is the evaluation of PL-SFTA and PLFaultCAT for the reuse of safety analysis assets in a product line. The context is a safety-critical product line of spacecraft developed as a multi-agent system. Keywords: reusable safety analysis assets, safety aspects of reuse, product-line software fault tree analysis, multi-agent system product lines.
1 Introduction Software product-line engineering (SPLE) is a key enabling technology for reuse. It provides a proactive and systematic approach for the design and development of systems to create a set of similar products, a product line, from reusable assets. A software product line (SPL) is defined as "a set of software-intensive systems sharing a common, managed set of features that satisfy the specific needs of a particular market segment or mission and that are developed from a common set of core assets in a prescribed way" [1]. SPLE supports reusability by developing a set of products that share core commonalities and differ via a set of managed variabilities [13] and has been shown to be able to reduce the design, development and production time and cost of systems through the reuse of code and non-code artifacts [1]. Engineering for safety-critical systems, such as cardiac pacemakers [10] and medical imaging systems [11], has adopted a SPLE approach to take advantage of reusable artifacts during design and development. To maintain the safety properties requisite for critical systems, safety analysis techniques and tools specific to SPLE had to be created to accommodate the variability inherent in a SPL while also producing reusable artifacts that can be used for all product-line members [10]. S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 160–169, 2009. © Springer-Verlag Berlin Heidelberg 2009
Evaluating the Reusability of Product-Line Software Fault Tree Analysis
161
Product-Line Software Fault Tree Analysis (PL-SFTA) [2] [6] extends traditional Software Fault Tree Analysis (SFTA) [8] by incorporating SPLE to produce reusable safety analysis assets. Unlike traditional SFTA, PL-SFTA develops fault trees that incorporate the variabilities amongst the SPL members to provide reusable safety analysis assets for the entire SPL. PL-SFTA is supported by a tool, PLFaultCAT [6], that enables this reuse by automatically producing the fault tree for each product-line member from the PL-SFTA. The goal is to support the safety analysis needed on a new product-line member with a less costly and more automated process. This paper furthers the argument that PL-SFTA and PLFaultCAT supply a beneficial safety analysis technique and tool. Specifically, the contribution of this paper is an evaluation of the degree to which their generated reusable safety analysis assets can be directly applied to new product-line members within SPLE, including: • A description of how PL-SFTA and PLFaultCAT systematically capture and reuse non-code safety analysis assets for safety-critical product lines • An evaluation of the degree to which the safety analysis assets developed using PL-SFTA can be reused toward new product-line members using a significant case study based on a NASA-proposed multi-agent system product line (MAS-PL) • An assessment of the degree to which the PLFaultCAT tool reduces the effort needed to construct the safety analysis products for a new member from the reusable product-line safety analysis assets • A discussion of the implications of the evaluation of PL-SFTA and PLFaultCAT on the degree to which software engineering artifacts can be reused for MAS-PLs compared to traditional SPLs This work is a part of a larger effort that investigates how safety-critical SPLs can be designed and developed with the support of SPL-specific, reusable safety analysis techniques. The long-term goal is to provide safety analysis assets for new productline members in a timely and cost-efficient manner. The remainder of the paper is organized as follows. Section 2 reviews related work. Section 3 summarizes the PAM MAS-PL case study used here for evaluation. Section 4 describes PL-SFTA in the context of SPLE. Section 5 provides an analysis of our empirical results regarding the reusability of the PL-SFTA safety analysis assets. Section 6 discusses the results from our experimental evaluation and their implications for MAS-PLs and SPLs. Finally, Section 7 provides concluding remarks.
2 Related Work SPLE supports the systematic planning, design and development of a family of software systems through understanding, controlling and managing their common characteristics and differences. SPLE develops a family of products and relies on the analysis of the commonalities and variabilities of the product-line members prior to their development. Following Weiss and Lai [13], we specify a SPL using a Commonality and Variability Analysis (CVA) to document the SPL’s commonalities (i.e., requirements of the entire product line), variabilities (i.e., specific requirements not contained in every member of the product line) and dependencies (i.e., constraints amongst selection of the variable features).
162
J. Dehlinger and R.R. Lutz
In previous work [2] [3], we have integrated the Family-Oriented Abstraction, Specification and Translation (FAST) SPLE methodology [13] into Agent-Oriented Software Engineering (AOSE) to enable the analysis and design of MAS-PL. In the domain engineering phase, the MAS-PL’s requirements are defined and specified using our Gaia-PL methodology [2]. The application engineering phase then reuses the software engineering artifacts developed in the domain engineering phase to build new product-line members, in this case software agents within the MAS-PL. There has been little related work to date specifically in safety-critical SPLs. Prior work in software safety [8] and in reuse for safety-critical systems [9] has not dealt directly with SPLE safety analyses. On the other hand, prior work in SPLE has not addressed the additional, high-assurance needs of safety-critical SPLs [1] [13]. To provide safety assurances for critical SPLs, we developed PL-SFTA and its tool support, PLFaultCAT [5] [6], to allow for the creation of fault trees for a SPL while supporting the reuse inherent in SPLE. A fault tree is a directed AND/OR graph that represents a hazard and its contributing causes. Each node is an event or condition that can contribute to the occurrence of the hazard [8]. In addition to supporting the development and reuse of safety analysis artifacts for critical SPLs, PLFaultCAT provides additional, automated safety analyses to identify failure points and safetycritical requirements [5]. These safety analysis results, when developed during the domain engineering phase, can be applied to all product-line members. Other SPLE-specific safety analysis techniques, including [4] [7] [10], have provided systematic approaches for conducting safety analyses on critical SPLs without studying the extent to which the resulting artifacts can be reused.
3 The Prospecting Asteroid Mission To evaluate this work, we used requirements based on the Prospecting Asteroid Mission (PAM), a NASA-proposed concept mission based on the Autonomous NanoTechnology Swarm (ANTS) technology to explore the asteroid belt [12]. This mission will consist of up to 1,000 spacecraft that can autonomously form subswarms to investigate asteroids of interest. Except for a spacecraft’s scientific instrumentation specialties, each PAM spacecraft has identical hardware. Each PAM spacecraft will be designated as a leader, a messenger or a worker [12]. A leader will determine the types of asteroids and data to pursue and will coordinate the efforts of worker spacecraft. A messenger will coordinate communication among spacecraft and with the Earth. Each worker will perform scientific investigation using its specialized equipment (e.g., a spectrometer). Within the PAM swarm, there is significant redundancy for each spacecraft type since 60-70% of the PAM spacecraft could be lost over the duration of the mission due to failures, collisions, etc. To preserve mission-critical requirements, additional capabilities (i.e., product-line variabilities) are given to some spacecraft to achieve redundancy at the swarm level through reconfiguration and adaptation. For example, some spacecraft may be able to switch at runtime from messenger to leader in response to loss or failure of other spacecraft, or to be tasked with monitoring for an impending solar storm (an optional variability). The design and development of the PAM spacecraft as a MAS-PL would allow for the reuse of software engineering assets during design and development. In the
Evaluating the Reusability of Product-Line Software Fault Tree Analysis
163
context of SPLE, the safety-related, commonality requirements include the navigation and guidance capabilities, collision avoidance, solar storm protection, etc. Additionally, each of the PAM spacecraft will have similar requirements related to selfcoordination, self-healing and self-optimization behaviors (i.e., requirements).
4 Product-Line Software Fault Tree Analysis Using PLFaultCAT This section describes the creation, analysis and reuse of a PL-SFTA for the safetycritical MAS-PL described in Section 3. The creation of the PL-SFTA occurs during the domain engineering phase of SPLE and constructs the safety analysis artifacts reused for specific product-line members in the application engineering phase. 4.1 Domain Engineering – Development of Reusable Safety Analysis Artifacts The development of the PL-SFTA using PLFaultCAT consists of three steps: Step 1. Identify a root node hazard(s) and develop intermediate node tree. The root node of a fault tree represents a potential hazard the system design and implementation should mitigate. This hazard may be known from an existing Preliminary Hazard Analysis [8] or from a product-line Software Failure Modes, Effects and Criticality Analysis (SFMECA) [4]. From the root node, a backward search is done to find causal, contributing events. Through gathering the causal events, an intermediate node tree is constructed to establish the cause-event hierarchy. The intermediate node tree, while not necessary in the construction of a PL-SFTA, aids in jump-starting the organization and analysis of the PL-SFTA and serves as the input to PLFaultCAT. Essentially, the intermediate node tree represents a typical fault tree without the Boolean logic gate relationships between causal events and effects. Step 2. Refine intermediate node tree and document in PLFaultCAT. The intermediate node tree may contain nodes that do not reflect the level of detail needed. Thus, domain expertise, and/or the use of other safety analysis artifacts like SFMECA [4], may be needed to analyze the tree for completeness, capture additional events leading to a failure (e.g., events from the environment) and refine nodes. The domain expertise is additionally needed to determine the necessary logical combination of the children nodes to cause the parent node, as is done in traditional fault tree analysis [8]. As with any FTA, the reliance on domain expertise means that the PL-SFTA is only as good as the accuracy and completeness of the information used to create it. Step 3. Consider the influence of commonality and variability requirements on all leaf nodes. This step employs a bottom-up approach to analyze each leaf node of the intermediate SFT and determines which commonality and/or variability requirements contribute to causing the root node event to occur. In doing this, we associate the range of commonality and variability choices for any individual product-line member with how it might influence a particular hazard. Not every commonality or variability will have an influence or appear within any given fault tree. However, every leaf event node should have an associated commonality, variability, and/or basic (primary) event (e.g., an environment or user input). Considering the influence of a present or
164
J. Dehlinger and R.R. Lutz
Fig. 1. Associating SPL requirements to the leaf nodes of a PL-SFTA in PLFaultCAT
absent variability on an event is straightforward; we analyze the influence of the variability being present within the product and not functioning as designed. If, however, the node relates to a commonality rather than a variability, we link the fault tree’s leaf node with the appropriate commonality. Using PLFaultCAT makes associating a commonality and/or variability with a failure node straightforward. The PLFaultCAT interface, shown in Figure 1, allows labels for "Basic Event" nodes, depicted as circles, as a Commonality or Variability as well as defining a label or ID for the variability (i.e., the textbox under the heading "Variability ID"). The application of these three steps, using the SPL requirements documented in a CVA and a list of hazards to be mitigated, constructs a PL-SFTA that encapsulates the safety analyses of all product-line members. Figure 2 provides the PL-SFTA for the PAM MAS-PL for the hazard “Spacecraft to Asteroid Collision” depicting the failure nodes and the associated SPL requirement leaf nodes. 4.2 Application Engineering – Derivation and Reuse of Safety Analysis Artifacts The development of a PL-SFTA, described in Section 4.1, enables the reuse of this safety analysis artifact to derive the SFT for a specific product-line member during the application engineering phase. We describe this process in this section. Step 1. Select the variabilities for a new product-line member. A new product-line member is defined through the selection of which variabilities or features to include from the CVA. A product-line member is created by selecting the variabilities that it will contain and defining the values of the variabilities. PLFaultCAT supports the selection of a new product-line member’s variability requirements by providing a checkbox window that presents all possible variabilities for the SPL. PL-SFTA does not itself enforce or check the dependencies prescribed in the CVA. Other tools, such as DECIMAL [5], are capable of enforcing the dependencies and constraints detailed in the CVA for large, complex SPLs. PLFaultCAT is used after the choice of variabilities has been determined to be legal.
Evaluating the Reusability of Product-Line Software Fault Tree Analysis
165
Fig. 2. PL-SFTA for the PAM MAS-PL hazard “Spacecraft to Asteroid Collision”
Step 2. Generate the product-line member fault tree using PLFaultCAT. After establishing and verifying a product-line member, we prune the product-line SFTA to create a baseline SFTA for the new system. The pruning process, described fully in [2] [6], first uses a depth-first search to automatically remove the subtrees that have no impact on the product-line member being considered and then relies on a small amount of domain knowledge to further collapse and prune the SFTA. A subtree within the PL-SFTA will have no impact if all the leaf nodes of that subtree contain variability requirements not included for the specific product-line member. The pruning errs on the side of caution to derive the product-line member’s SFT from the PLSFTA since it only marks the subtrees that can be removed without review and does not actually do any pruning. This is advantageous from a safety perspective because it simply indicates those subtrees where neither commonalities nor selected variabilities can be found in the subsequent children nodes. This algorithm then defers the actual pruning to the domain experts, as described in the next step. Figure 3 shows a portion of the resulting product-line member SFT derived from the PL-SFTA shown in Figure 2 for the PAM MAS-PL for the hazard “Spacecraft to Asteroid Collision. Step 3. Apply domain knowledge. After removing the subtrees that had no bearing on the product-line member under consideration in Step 2, the fault tree may be able to be further pruned and/or collapsed within PLFaultCAT. However, this step requires domain knowledge and illustrates the limit to fully-automated PL-SFTA reuse. Removal of subtrees will often lead to orphaned logic gates or other opportunities to safely simplify the fault trees of a new product-line member. If removing orphaned OR gates when there is only one causal event remaining, we collapse the lower event into the parent event. If there is only one commonality or variability leaf node remaining, we attach it to the parent event and remove the OR gate. When AND gates are involved, more caution is required. Intuitively, if at least one input line to an AND gate is removed, the output event is impossible. However, it was found that this is not always the case, so each removal of an AND gate warrants further scrutiny. The
166
J. Dehlinger and R.R. Lutz
Fig. 3. Derived SFT from the PL-SFTA for a specific spacecraft in the PAM MAS-PL
clean-up of the derived SFTs for the new product-line member(s) presented in this step is a manual process and must be pursued with care. Enough information should be retained within the product-line member's fault tree for future hazard analysis and mitigation strategies. The application of domain knowledge helps in the derivation of the SFTs for a new product-line member by removing extraneous nodes and focusing attention on nodes that may contribute to failures in a specific product-line member. This provides additional assurance for the reused safety analysis asset. The following section evaluates the claim that the application of these three steps, which reuse the PL-SFTA to derive specific safety analysis assets for a product-line member, provides safety analyses more efficiently and at a reduced cost.
5 Evaluation of Safety Analysis Asset Reuse The application of the PL-SFTA to the PAM case study developed four fault trees for the hazards: 1. Spacecraft to Spacecraft Collision; 2. Spacecraft to Asteroid Collision; 3. Spacecraft Solar Storm Damage; and, 4. Failure to Detect Impending Solar Storm. The PL-SFTA associated 85.7% of the commonalities and 72.5% of the variabilities with at least one of the leaf nodes i the set of fault trees. In the domain engineering phase, PLFaultCAT did not provide significant advantages over other tools in PAM beyond additional opportunity to embed textual hazard analysis information in the fault tree. This allowed a cross-check of the information provided in the fault tree to previously derived safety requirements. In the application engineering phase, PLFaultCAT provided significant reuse advantages by exercising the pruning method outlined in Section 4. In the case study, approximately 54% of the failure nodes in the PL-SFTA were found to be common to
Evaluating the Reusability of Product-Line Software Fault Tree Analysis
167
Table 1. Results of the Application of PL-SFTA to the PAM Case Study Total Failure Nodes 82
Common Failure Nodes 64
Spacecraft to Spacecraft Collision
84
61
Spacecraft Solar Storm Damage Failure to Detect Solar Storm
87 91
52 13
Hazard Spacecraft to Asteroid Collision
% Commonality Requirements
Core Reuse
PLFaultCAT Automation
88.5%
78.0%
72.2%
63.8%
72.0%
82.1%
60.0% 6.7%
59.8% 14.3%
72.2% 93.8%
all 160 unique spacecraft of the PAM MAS-PL. That is, the minimum expected reuse of the PL-SFTA safety analysis asset for any given PAM spacecraft would be 54%. Table 1 provides the results for each of the hazards examined using PL-SFTA for the PAM MAS-PL case study. The “Hazard” column describes the root node hazard of a fault tree; the “Total Failure Nodes” column shows the total number of failure nodes of a fault tree from Steps 1-3 described in Section 4; the “Common Failure Nodes” column gives the number of failure nodes that will be common to all productline members of the PAM MAS-PL; the “% Commonality Requirements” is the percentage of the requirements associated to the leaf nodes of a fault tree that are commonality requirements; the “Core Reuse” column is the percentage of the failure nodes that are common to all product-line members of the PAM MAS-PL; and, finally, the “PLFaultCAT Automation” column shows the percentage of the nodes that could be safely and automatically pruned from the PL-SFTA using PLFaultCAT. Although the overall reuse of the PL-SFTA in this study is approximately 54%, in most cases the reuse potential of a fault tree in the PL-SFTA was even higher, in the 60-80% range. The only exception was the “Failure to Detect a Solar Storm” fault tree which had a 14% minimum reuse potential. The reason is that the major contributing factor to a lower reuse potential for the safety analysis assets of the PL-SFTA is its relation to the requirements. The fault trees for “Spacecraft to Spacecraft Collision”, “Spacecraft to Asteroid Collision” and “Spacecraft Solar Storm Damage” all had root nodes directly related to product-line commonalities. Since each of these requirements necessitates a PAM spacecraft to prevent the hazards outlined in these fault trees, all PAM spacecraft will be equipped with the functionality to prevent those hazards. As a result, a large portion of the PL-SFTA could be reused regardless of the specific configuration of the spacecraft. However, for a hazard that stems from a product-line variability, such as the “Failure to Detect Solar Storm” hazard, the reuse potential is much less since the failure of the product-line variability to mitigate against the hazard is only found in a subset of the product line’s members. This case study also found that, of failure nodes that could be safely pruned for a new product-line member, PLFaultCAT was able to automatically perform a minimum of 72% of the trimming without losing necessary information. Thus, 28% of the work was left to be done manually. This metric reflects the effort saved in reuse of the PL-SFTA safety analysis assets. The automation that PLFaultCAT does when pruning for a specific member(s) is sensitive to the number of Boolean AND gates in the fault tree. As a result of the conservative pruning approach, PLFaultCAT will not automatically remove the AND gates as a safety precaution. Thus, PLFaultCAT does more automated pruning for fault trees with fewer AND gates. Despite this, in the PAM case study the automation to manual effort was at least a 3:1 ratio.
168
J. Dehlinger and R.R. Lutz
These results compare favorably to those of an initial case study we performed in [6] on the Floating Weather Station (FWS) product line [13]. Unlike the study presented here, the FWS case study was a smaller, traditional SPL (i.e., not agent-based). In the FWS study, we found that a smaller portion of the PL-SFTA nodes, 45%, was common to all products of the product line. However, like the PAM case study, the FWS study found that PLFaultCAT was able to automatically prune 70% of the nodes that could safely be pruned. The difference in the percentage of common failure nodes in the two studies (45% for the FWS; 54% for PAM) is likely due to the difference in the types of applications in the case studies. That is, the results reported in the FWS study reflect the application of PL-SFTA to a single fault tree for a case study consisting of fewer than 20 requirements. More importantly however, is that the product-line members of the FWS did not share the same safety concerns as they did in the PAM study. Shared safety concerns seem to result in more reuse.
6 Discussion and Implications The agent characteristics of the PAM case study as well as the types of variabilities that were present had a significant impact on our results. The PAM spacecraft will have the responsibility for protecting and healing itself from the possible risks of space exploration. For this reason, each spacecraft is to be equipped with the behavior to protect itself from the types of hazards modeled in the PL-SFTA. Further, the variabilities of the PAM MAS-PL reflected the differing types of scientific investigation possible on the spacecraft and had only a minor impact on the leaf nodes. The implication of this result is that a PL-SFTA may best suit a MAS-PL rather than a traditional SPL since the agents of a MAS-PL will typically also include selfprotecting and self-healing characteristics as commonalities and may have variabilities that are less likely to be safety-critical. For traditional SPLs that have few variabilities that will impact the safety of a system, a PL-SFTA can be applied to achieve comparable results found in this study. For traditional SPLs with a large number of variabilities that can impact the safety of a system, such as the FWS, the reuse of the PL-SFTA safety analysis assets is far more efficient, especially for large SPLs, than to serially construct SFTAs for each of the desired product-line members. A concern for performing safety analysis on critical SPLs is whether the technique is scalable as the SPL grows more complex by incorporating more variabilities and product-line members. From the experience of applying the PL-SFTA to the PAM case study, it appears that our method and tool will scale adequately. This is because most of the added complexity in a large SPL lies in the domain engineering phase when the PL-SFTA is constructed. In [4], we provide a structured process to construct the SFMECA for a MAS-PL from the requirement specifications of the Gaia-PL methodology [2] [3]. Since the construction of the PL-SFTA relies heavily on the aid of a SFMECA, the scalability is at least as robust as that of the SFMECA.
7 Concluding Remarks This paper described and evaluated the structured reuse of SFTA documents for a product line of collaborating spacecraft developed as a multi-agent system. Results
Evaluating the Reusability of Product-Line Software Fault Tree Analysis
169
showed that reuse of the PL-SFTA assets across this safety-critical product line reduced effort over serial construction of SFTAs for each spacecraft, with 54% of the failure nodes common to the 160 unique spacecraft. The implication of this for other safety-critical product lines is that SPLs built as multi-agent systems, which often incorporate adaptive and self-healing behaviors as commonalities, fit especially well with PL-SFTA reuse. More generally, the PL-SFTA evaluation recorded advantages in expanded reuse of safety-analysis assets across a safety-critical SPL. Acknowledgements. This research was supported by the National Science Foundation under grants 0204139, 0205588 and 0541163.
References [1] Clements, P., Northrop, L.: Software Product Lines. Addison-Wesley, Boston (2002) [2] Dehlinger, J.: Incorporating Product-Line Engineering Techniques into Agent-Oriented Software Engineering for Efficiently Building Safety Critical Multi-Agent Systems, Ph.D. Thesis. Iowa State University (2007) [3] Dehlinger, J., Lutz, R.R.: A Product-Line Approach to Promote Asset Reuse in MultiAgent Systems. In: Garcia, A., Choren, R., Lucena, C., Giorgini, P., Holvoet, T., Romanovsky, A. (eds.) SELMAS 2005. LNCS, vol. 3914, pp. 161–178. Springer, Heidelberg (2006) [4] Dehlinger, J., Lutz, R.R.: Bi-Directional Safety Analysis for Product-Line, Multi-Agent Systems. In: ACM SIGBED Review: Special Issues on Workshop Innovative Techniques for Certification of Embedded Systems, vol. 3(4) (2006) [5] Dehlinger, J., Humphrey, M., Padmanabahn, P., Lutz, R.R.: Decimal and PLFaultCAT: From Product-Line Requirements to Product-Line Member Software Fault Trees. In: 29th International Conference on Software Engineering Companion, Minneapolis, MN, pp. 49–50 (2007) [6] Dehlinger, J., Lutz, R.R.: PLFaultCAT: A Product-Line Software Fault Tree Analysis Tool. Automated Software Engineering Journal 13(1), 169–193 (2006) [7] Feng, Q., Lutz, R.R.: Bi-Directional Safety Analysis of Product Lines. Journal of Systems and Software 78(2), 111–127 (2005) [8] Leveson, N.G.: Safeware: System Safety and Computers. Addison-Wesley, Boston (1995) [9] Leveson, N.G., Weiss, K.A.: Making Embedded Software Reuse Practical and Safe. In: ACM SIGSOFT Software Engineering Notes, pp. 171–178 (2004) [10] Liu, J., Dehlinger, J., Lutz, R.: Safety Analysis of Software Product Lines Using StateBased Modeling. Journal of Systems and Software 80(11), 1879–1892 (2007) [11] Schwanke, R., Lutz, R.: Experience with the Architectural Design of a Modest Product Family. Journal of Software Practice and Experience 34(13), 1273–1296 (2004) [12] Sterritt, R., Rouff, C., Rash, J., Truszkowski, W., Hinchey, M.: Self-* Properties in NASA Missions. In: Proceedings International Conference on Software Engineering Research and Practice, Las Vegas, NV, pp. 66–72 (2005) [13] Weiss, D.M., Lai, C.T.R.: Software Product Line Engineering: A Family-Based Software Development Process. Addison-Wesley, Boston (1999)
Feature-Driven and Incremental Variability Generalization in Software Product Line Liwei Shen, Xin Peng, and Wenyun Zhao School of Computer Science, Fudan University, Shanghai 200433, China {061021062,pengxin,wyzhao}@fudan.edu.cn
Abstract. In the lifecycle of a software product line (SPL), incremental generalization is usually required to extend the variability of existing core assets to support the new or changed application requirements. In addition, the generalization should conform to the evolved SPL requirements which are usually represented by a feature model. In this paper, we propose a feature-driven and incremental variability generalization method based on the aspect-oriented variability implementation techniques. It addresses a set of basic scenarios where program-level JBoss-AOP based reference implementations respond to the feature-level variability generalization patterns. It also provides the corresponding guidance to compose these patterns in more complex cases. Based on the method, we present a case study and related discussions.
1 Introduction Software product line (SPL) engineering [1] promises to improve time-to-market, cost, productivity, and quality in a proactive mode, i.e. predicting and implementing all the application variations in advance through domain engineering. However, the proactive approach only suits organizations that can predict their product line requirements well into the future and have the time and resources for a long waterfall-like development cycle [2]. Most of the real SPLs are developed and maintained in a mixed mode of proactive and reactive approaches. Usually, an initial SPL platform involving one or several product variations will be developed first. After that, the SPL will evolve in an incremental and iterative mode. In each iteration, more product variations are recognized and included, and the SPL platform is extended and improved. In the SPL lifecycle, incremental generalization is usually required to extend the variability of the existing core assets to support the new or changed application requirements. The term generalization named by Thum et al. [4] indicates the case when new products are added and no existing products are removed. It is a part of the term refactoring defined by Alves et al. [3] as “a change made to the structure of a SPL in order to improve its configurability, make it easier to understand, and cheaper to modify without changing the observable behavior of its original products”. In our work, we focus on variability increments, e.g. introducing new variation point or variant. It is the generalization that usually aims to add more variations based on the existing core assets. On the other hand, the generalization should conform to the evolved SPL requirements, which are usually represented by a feature model [4, 5, 6, 12, 17]. S.H. Edwards and G. Kulczycki (Eds.): ICSR 2009, LNCS 5791, pp. 170–180, 2009. © Springer-Verlag Berlin Heidelberg 2009
Feature-Driven and Incremental Variability Generalization in Software Product Line
171
In this paper, we propose a feature-driven and incremental variability generalization method based on the aspect-oriented variability implementation techniques. We identify a set of basic scenarios which address the generalization patterns on the feature model, representing the requirement-level variability evolution, and provide program-level reference implementation based on JBoss-AOP for each of the pattern. Then, we can obtain incremental generalization guidance for more complex variability evolution by composing the basic feature model generalization patterns and deriving the integrated reference implementations. The paper is structured as follows. Section 2 presents the background of variability generalization in the SPL. Section 3 introduces the basic generalization scenarios and their composition guidance. Section 4 demonstrates the method with a case study. Later in Section 5 and Section 6 we present discussions and related work respectively. Finally we conclude the paper and plan the future work in Section 7.
2 Background: Variability Generalization in SPL In our method, we use the standard feature model as shown in Figure 1(a) to capture the feature-level variability evolutions. The three types of variation points are optional, alternative and OR features. On the program level, we employ JBoss-AOP as the reference implementation technique for the variations, since aspect-oriented programming (AOP) [7] has been proven an efficient way for the variability implementation [16]. Moreover, the obliviousness characteristic of AOP [8], which implies that the developer of the initial core assets need not to be aware of and prepare for the future variability evolutions, supports stepwise variability increment without intruding the existing programs. JBoss-AOP [9, 10] is one of the most popular tools in the AOP community. In JBoss-AOP, an aspect is defined by an interceptor and a pointcut. The interceptor is the same as the advice and it is programmed as a Java class (implements org.jboss.aop.advice.Interceptor). The pointcut is defined in XML (jboss-aop.xml) and related interceptors are bound to it. The advantage of applying JBoss-AOP as the implementation technique will be discussed in section 5.1. Feature tangling and scattering complicate the traceability from features in a feature model all along to the program level units, usually classes or methods in an object-oriented language. It means there may be several program units, especially methods, contributing to a single feature, while a single program unit, especially a class, may contain implementations for several features. In our paper, we assume that each feature is implemented by one or more methods in the same class or in different classes, i.e. a one-to-many relationship between features and methods. The variability implementation with JBoss-AOP can be seen in Figure 1(b). For the sake of simplicity, we assume further that one feature corresponds to one method. A mandatory feature is connected through the normal method and constructor invocations. An optional feature is implemented by weaving the method into the base program through an interceptor. The implementation for an alternative feature adopts the inheritance approach, i.e., each method corresponding to a variant should reside in a class that inherits the base class containing the base method and all of them ought to keep the same method signature. Then the feature can be implemented
172
L. Shen, X. Peng, and W. Zhao
by one of its variants through instantiating the variant-related class when customized. We call it object replacement mechanism, which is handled by an aspect. The implementation for an OR feature also follows the object replacement mechanism but it is replaced at runtime. Therefore a selecting program is necessary in the interceptor which helps to determine the variant. In addition, the interceptor codes for implementing alternative and OR features are undetermined at design time since the variant to be chosen and the variants included cannot be decided until the product derivation phase. So, these two kinds of interceptors are suggested to follow the certain implementation templates and they will be reified to support the object replacement when the SPL is customized. Feature model generalization is a transformation performed to increase the variability of a SPL. In [3], Alves et al. propose twelve types of unidirectional feature model refactorings. Their work concentrates on feature-level variability refactoring only, while we focus on feature-driven program-level variability generalization. On the other hand, in this paper we only consider the generalizations which are part of the feature refactoring types that add the variability incrementally, i.e. improve the configurability by introducing new variation points or variants.
Fig. 1. (a) Standard feature model
(b)Variability implementation with JBoss-AOP
3 Basic Generalization Scenarios and Their Composition We identify six basic generalization scenarios, each of which includes a feature generalization pattern and the corresponding reference implementation. Based on the basic scenarios, we provide guidance for scenario composition to handle the more complex cases. Furthermore, we still follow the assumption that one feature corresponds to one method in describing the basic scenarios in Section 3.1, while feature tangling and scattering are taken into consideration in Section 3.2. 3.1 Basic Generalization Scenarios The scenarios are illustrated in Figure 2, where the legends follow those in Figure 1. In particular, the squares filled with color indicate new or modified entities. Besides the graphs, the snippets of the reference implementations when deriving a product are illustrated in Figure 3. The snippets include the method body of method invoke in the interceptor class as well as the XML segment of the aspect binding in jboss-aop.xml.
Feature-Driven and Incremental Variability Generalization in Software Product Line
173
Fig. 2. Six basic generalization scenarios
3.1.1 AddOptional This scenario describes adding a new optional feature B into the feature model. In the program level, a new aspect is introduced. The pointcut is the method (ClassA.foo()) which intends to invoke the new method implementing the added feature. The interceptor thus includes the invocation to the new method which can only be executed before or after the base method. The implementation snippets when feature B is included can be seen in Figure 3(a). 3.1.2 MandatoryToOptional This scenario indicates transforming an existing mandatory feature B to an optional one. It’s another situation to implement optional features besides AddOptional. In the program level, an aspect is introduced to weave into the existing programs. The pointcut points to the method (ClassB.bar()) which corresponds to the optional feature. The interceptor then overrides the target method (not really modify it) by writing an
174
L. Shen, X. Peng, and W. Zhao
Fig. 3. AOP snippets for the atomic generalization patterns
empty method body or simply returning a nonsensical value if the method should have a return value. As a result, the aspect takes effect when the new optional feature is removed in a product, and vice versa. The implementation snippets when feature B is removed are shown in Figure 3(b). 3.1.3 SingleAddVariant This scenario describes adding a variant to an existing single feature, i.e. the feature without variants, to make it alternative. We cannot implement the new alternative feature using the method in Section 2 where there is a super-class acting as a placeholder at the beginning. Explaining the reason using the graph, we can see that the invocation from ClassA to ClassB is fixed, so it’s not practical to alter ClassA to invoke a class created as a super-class and then make ClassB inherit the new class. Therefore, we adopt a new method based on the object replacement mechanism. ClassC is firstly defined as a subclass of ClassB where the method bar() should be overridden. Secondly an aspect is created. Its pointcut is ClassB’s constructor while its interceptor instantiates ClassC to get an object taking the place of ClassB. Once feature C is selected, the aspect should be bound in jboss-aop.xml. Contrarily, the aspect won’t be woven if the original feature B is selected. The interceptor code and xml segments when feature C is bound are shown in Figure 3(c). 3.1.4 AlternativeAddVariant This scenario is captured when a new variant is added to an existing alternative feature. There are two approaches to implement an alternative feature: SingleAddVariant (it becomes alternative after generalization) and the idea from section 2 (it is alternative in the beginning). They are different in the pointcut definition and are illustrated in the second and third rows respectively. However, the underlying generalization method for the two situations is unique, both following the object replacement mechanism. We define the new class (ClassD) as a subclass of the one (ClassX and ClassB in two styles respectively) invoked by ClassA. The pointcut remains the same, pointing to the constructor. The interceptor codes are undetermined since the variant choice decision is unknown at design time. However, the generalization
Feature-Driven and Incremental Variability Generalization in Software Product Line
175
pattern provides the implementation template for the interceptor, which is reified when the SPL is customized. The interceptor template for the reference implementation can be concluded from Figure 3(c). The intercepted class and the chosen variant are the variable points in the template. 3.1.5 AlternativeToOR This scenario transforms an existing alternative feature to an OR feature, i.e. more variants can be included in a product and the choice is made at runtime through a selecting program. Similar with AlternativeAddVariant, two approaches can implement the alternative feature. However, no matter which approach is adopted, the only thing is to modify the interceptor following a new template which contains the selecting logic for the future included variants. There is a set of if clauses each of which has a condition and a corresponding object instantiation sentence. Sometimes the application requires the human interaction to do the decision, so the interceptor may have to provide a user interface to acquire the human’s choice. The reference implementation snippets after SPL customization are shown in Figure 3(d) and the template can be concluded from them. 3.1.6 ORAddVariant This scenario indicates adding a new variant to an existing OR feature. The reference implementation containing the pointcut definition and the interceptor template keeps the same with AlternativeToOR. If the new variant is to be included in the derived product, we just need to ensure that the selecting program in the interceptor embodies the if clause involving the new variant. 3.2 Guidance for the Composition of Basic Generalization Scenarios In reality work, we will come up against situations that cannot be solved based on a single basic generalization scenario but their integration. This is caused by the continuous SPL variability evolution as well as the feature tangling and scattering. In this section, we will put forward an incremental generalization guidance for more complex generalization scenario cases by composing the basic feature model generalization patterns in order and deriving the integrated reference implementation. The phases are as following: (1) Identify the set of ordered basic feature model generalization patterns for each variation point. Under the circumstances of a complicated generalization scenario, the variability evolution may emerge in the different points, while in a certain point the evolution continues. Hitherto, it is an ad hoc phase for the developers to address them. (2) For each variation point, adopt the corresponding reference implementations. In this phase, the pointcuts as well as the interceptors are defined in the program level. One feature model generalization may cause the implementation evolution in several parts due to the feature tangling. Furthermore, the implementations for the last three scenarios involve the same pointcut (the constructor) and the same interceptor, whereas the interceptor implementation is of different templates. In this situation, the interceptor should follow the last template within the set and the pointcut is preserved. (3) Find out the conflicts in reference implementations. Conflicts may appear when the reference implementations of different variant points involve the same pointcut
176
L. Shen, X. Peng, and W. Zhao
and they cannot be arranged in order. The typical situation is that two features with alternative or OR variability map to the methods in the same class, then the object replacement will bring mistakes when the two interceptors are both woven, i.e., the object can only be replaced by the later bound one. Under such circumstances, the implementations cannot be carried out and the developers should be informed to do the additional undesirable work such as modifying the base programs. (4) Customize the variability. When there is no conflict in the reference implementations, the binding states of the feature model variability can be determined, e.g. the optional feature is included or not, which variant is chosen for the alternative feature, etc. In the program level, it indicates the decision whether an interceptor will be bound to a pointcut (first three scenarios), or determine the implementation codes of an interceptor (last three scenarios).
4 Case Study In this section, a simplified case study is presented based on the composition guidance. The typical generalization case is described in the following sentences. Before generalization: an initial library management system provided the free service of borrowing books for the campus students. After generalization: the system was applied for the social use. Public readers were charged and they had to refill money to their accounts. In the beginning, the system received cash only. Along with the diversity in payment manner, the library system allowed readers to refill by credit card or check. Thus readers could choose one of the three kinds of payment when refilling. The generalization scenario is explicit then the feature model generalizations are easy to identify. Figure 4(a) represents the generalization related part in the feature model. We can see that a new optional feature with three variants has been added to the domain. The whole transformation is combined with a set of basic feature model generalization patterns in the following path: AddOptional + SingleAddVariant + AlternativeAddVariant + AlternativeToOR. In the program level illustrated in Figure 4(b), a new class CashRefill and a new interceptor NeedRefill_Interceptor are introduced first according to AddOptional. The interceptor not only helps to connect AccountMngUI and CashRefill, but also adds a widget in the UI that triggers the method invocation (codes in Figure 5a). In the process of the next three reference implementations, another two classes are introduced and both inherit CashRefill. In addition, the interceptor RefillType_Interceptor is initially introduced by SingleAddVariant and at last its implementation code follows the template in AlternativeToOR. In particular, the interceptor includes an inner class providing the UI for selecting. Since the simple traceability in the example, there is no conflict found in the implementations. The variation points are going to be customized. We assume that the feature AccountRefill is bound in a product, and the three variants are all included. Thus the codes of NeedRefill_Interceptor and Refi