43
Operationscanbedividedintoseveraltypesintermsofthissimplemodel.Someopera-
tionsjustchangethecontentsofparticularcells.Wecanlumptogetherthevarioustype-
specificoperationsonthecontentcells,andconsiderthemassubtypesofagenericchange
valueoperation.Anoperationcanalsochangethepropertiesoftheaddressingfunctionfora
datastructure.Forinstance,asortarrayoperationchangesonlythelocationsofthecells(or
theircontents),essentiallyrearrangingthecontentsofthecomposite.Otheroperationsmay
addnewcellstothestructure,whileothersmayremovecellsfromthestructure.Insertand
deleteoperationsonlistsareperhapsthecanonicalexample.
Onecriticalwayinwhichdatatypeandoperationaldefinitionsinteractisintheareaof
datastructureinvariantsthatmayneedtobeenforcedforadatastructuretobevalid.Any
editingoperationsmaysomehowaffectadatastructure’srequiredinvariants,andthusthe
representationofpermissibleoperations.Asortedlist,forinstance,wouldneednolocation
foraninsertionoperation,andindeed,ifonewasused,conflictswouldbemorelikely,as
separatepositionalinsertionswouldbeveryunlikelytosatisfythesortinginvariant.Itis
evenpossibleforanoperationtoimposeaninvariantonastructure.Thesortlistexample
mentionedpreviouslymightcreateanewinvariantthatwouldautomaticallyaffectthere-
sultsofanyoperationsinahistorythatcontainsit.Itwouldalsohaveapotentialconflict
withothersortingoperationsonthesamestructure.
2.3 Change-completenessandversion-completeness
Oncetheparticularoperationsrequiredforagivendatastructureandupdatepattern
havebeenselected,theissueremainsofhowthosechangesaretointeractandbeorganized
intohistories.Thissectionconsiderssomeofthehigh-levelissuesofchange-changeinterac-
tioninhistories,potentialconflictsanddifferentpossibilitiesforresolution.Theexamples
ofoperationsinthediscussionareconcretelyanchoredintheproblemofrepresentingse-
44
quencesandtheirediting,althoughtheissuesapplytoothertypesofaggregatedatastruc-
turesaswell.
Therearetwofundamentalpropertiesthatmightbesatisfiedbyachange-orientedrepre-
sentationofstatechanges.Onepossibilityisasetofoperationsthatisversion-complete.We
willdefinethetermversion-completetorefertoasetofoperationtypesthatsufficestorep-
resentallthepossibledifferencesbetweensignificantstates(versions)ofadataobject.
Whenthegoalistorepresentonlyparticularstatesofdataobjects,withoutconcernfor
combiningormodifyingchangehistories,aversion-completesetofchangesisallthatis
neededtomeetthefunctionalrequirement.
Withaversion-completesetofoperationtypes,anyversiongraphcanberepresentedby
setsofchangesinahistorystructure.Suchrepresentationsareoftenusedasastorageopti-
mizationtechniquetoreducetheoverheadanddataduplicationsofsavingmanydistinct
butsimilarstates.Suchrepresentationsarechosensothatthestoragetoholdallneeded
versionsofanobjectwillbeassmallaspractical.Thepreciseoperationtypesandtheirrep-
resentationarecriticaltosatisfyingasystem’stimeandspaceefficiencygoals,bothinterms
ofthespacerequiredtoholdtypicalhistories,andthetimerequiredtofindtherepresenting
anyparticularhistory.However,theactualoperationsusedarenotimportantinthemselves,
andthereareinfactmanypossibleoperationsets,withfairlysimplesemantics.
Version-completenessisnotaverydifficultpropertytoensure.Moredifficultistofinda
setofbasicoperationsthatischange-complete.Suchasetofoperationsissufficientnotonly
torepresentdifferencesamongarbitraryversions,butisalsochosentobe“natural”forthe
applicationareainquestion.Whilethismayinvolveveryspecializedoperationsofuseonly
inaparticularapplication,thereareinfactmanyusefulgeneralizedoperations,depending
onanapplication’srequirements.Onekeyissueindeterminingthenaturalnessofanopera-
tionsetforanapplication’sneedsiswhethertheoperationsdirectlycorrespondtoauser’s
actionsinusingtheapplication,ortoauser’smodelofwhatisbeingaccomplishedbythose
Previous Page Next Page