Abstract Handling Optional Features in Software Product Lines

  • 格式:pdf
  • 大小:141.72 KB
  • 文档页数:2

HandlingOptionalFeaturesinSoftwareProductLines

ThomasLeich,SvenApel,MarkoRosenmueller,GunterSaake

DepartmentofComputerScience,Otto-von-Guericke-University

Magdeburg,39106,Germany

Abstract

Softwareproductlineshavealongtraditionandwillgainmo-

mentuminfuture.FeatureOrientedProgramming(FOP)isa

designmethodologyandimplementationtechniquetobuildprod-

uctlinesbasedonfeatures.Featuresinteractwithothersinmany

ways.Inthispaperwefocusonstructuralinteractionsoffeatures

andespeciallyonhandlingoptionalfeatures.Wepresentourfirst

ideasdealingwithaprobleminthiscontext(a.k.a.featureop-

tionalityproblem).

1Overview

Softwareproductlinesaresubjectofongoingresearch.FOP

isadesignmethodologyandimplementationtechniqueto

buildproductlines[2].TheideaoftheFOPmodelisto

decomposesoftwareintoseparatemodularunits(features)

andtocomposestacksoffeaturestoderiveaconcretepro-

gram.Whenaddingnewprogramstoaproductline,exist-

ingfeaturesofotherprogramscanbereused.Thisisalso

knownasstep-wiserefinement.Thebenefitismaintainable,

comprehensiblesoftwarethatcanbeeasilyreused,config-

uredandextended[2].

CACBCCL1

L2

L3

Figure1:Stackofmixinlayers.

MixinLayers.Mixinlayersareoneappropriatetech-

niquetoimplementfeaturesinthesenseofFOP[2,8].The

basicideaisthatfeaturesareoftenimplementedbyacol-

laborationofclassfragments.Amixinlayerisastaticcom-

ponent,encapsulatingfragmentsofseveraldifferentclasses

(mixins)sothatallfragmentsarecomposedconsistently.

Figure1depictsastackofthreemixinlayers(L1-L3)in

topdownorder.Themixinlayerscrosscutmultipleclasses

(CA-CC).Theroundedboxesrepresentthemixins.Mixins

thatbelongtogetherconstituteacompleteclassarecalled

refinementchain.

FeatureC++.FeatureC++1isaC++languageex-

tensiontoimplementmixinlayers.InFeatureC++,mixin

layersarerepresentedbyfilesystemdirectories.Therefore,

theyhavenoprogrammaticrepresentation.Thosemixins

foundinsidethedirectoriesareassignedtobemembersof

theenclosingmixinlayers.Figure2depictsaclassandtwo

refinements(implementedasmixins).Refinementsarede-

claredbytherefineskeyword(Lines10,17).Usually,they

introducenewattributesandmethodsorextendmethods

1http://wwwiti.cs.uni-magdeburg.de/itidb/fcc/oftheirparentclasses(e.g.Line10-27).Toaccesstheex-

tendedmethodthesuperkeywordisused(Lines20,23,26).

2FeatureOptionalityProblem

Toexplainourideastosolvethefeatureoptionalityprob-

lemweuseaFOPmodelofastackproductline(adopted

from[7]).Figure2showsamodifiedversionofthisstack.

Thebasefeaturebaseimplementsbasicstackoperations

suchaspush(),top(),andpop().Theconcatfeatureex-

tentsthestackwithfunctionalityforcombiningtwostacks.

Theconcatmethodaddsthisfunctionality(Line11).

1//Layer../Stack/BaseStack/BaseStack.fcc2classstackOfChar{//thebasefeature3Strings;4voidempty(){s="";}5voidpush(chara){s=a+s;}6voidpop(){s=s.substring(1);}7chartop(){returns.charAt(0);}8};9//Layer../Stack/Concat/Concat.fcc10refinesclassstackOfChar{//theconcatfeature11voidconcat(stackOfChar&other){12while(!other.empty()){13push(other.top());14other.pop();}}15};16//Layer../Stack/Log/Log.fcc17refinesclassstackOfChar{//thelogfeature18voidconcat(stackOfChar&o){19cout<<"concat󰀩2󰀩stacks"<

Figure2:Refinements.

Thefeaturelogaddsloggingsupporttothestackprod-

uctline.Doingso,thebasicstackoperations(push(),

pop(),concat())arerefined.Thisisthecommonwayto

implementrefinementsinaFOPstyle.But,however,incer-

tainsituationthisleadstoaproblem:Ifwewanttoderive

astackwithloggingsupportandwithouttheconcatfea-

ture,wegetanerrorduringthecompilationprocess.Ifthe

concatfeatureisremovedthelogfeaturetriestoextenta

non-existingfeature.Thismayhappenbecausetheconcat

featureisanoptionalfeature.Thisproblemisalsocalled

thefeatureoptionalityproblemcausedinfeature-oriented

designs[7].

PrehoferproposeslifterstosolvethisprobleminFOP[7].

Liftersencapsulatefeaturedependenciesanddecouplefea-

tures.Theideaistoseparatethosepartsofafeaturethat

dependonotherfeatures(inlifters)fromthosethatarein-

dependent.Doingso,afeatureissplitintoseveralabstract(sub)features.Thegoalisthatdependentandindependent

featuresareseparatedintodifferentconcerns[7,4].

However,thisapproachhasitslimitations:Itisamain

goalofFOPtoencapsulateuserintuitiverequirementsinto

features,andmoreoverinaone-to-onepattern[3].Using

liftersenforcestheprogrammertointroduceadditionalab-

stractfeatures.Thus,theone-to-onemappingisbroken.

Furthermore,thispreventsfeaturecohesion.Cohesionis

thepropertyofafeaturetoencapsulateallimplementation

unitsthatcontributetothefeatureinonemodule[5].Fea-

turecohesionisimportanttoimplementandhandlelarge-

scalebuildingblocks.Theexplicitmappingofrequirements

ontoimplementedfeaturesensuresalong-life,maintainable

system[9].FeaturesinFOPhaveahighdegreeofcohe-

sion,butthisintroducesthefeatureoptionalityproblem.

Usingtheliftertocopewiththefeatureoptionalityprob-