Oscar Pastor · Juan Carlos Molina Model-Driven Architecture in Practice A Software Production Environment Based on Conceptual Modeling With48Figuresand35Tables 123 Authors OscarPastor DSIC,UniversitadPolitécnicadeValencia CaminodeVeras/n 46022Valencia,Spain [email protected] JuanCarlosMolina CARETechnologies,S.A. Pda.MadrigueresSud,44 03700Denia,Spain LibraryofCongressControlNumber:2007927169 ACMComputingClassification(1998):D.2,I.6,H.1,J.6 ISBN 978-3-540-71867-3 SpringerBerlinHeidelbergNewYork Thisworkissubjecttocopyright.Allrightsarereserved,whetherthewholeorpartofthematerial isconcerned,specificallytherightsoftranslation,reprinting,reuseofillustrations,recitation,broad- casting,reproductiononmicrofilmorinanyotherway,andstorageindatabanks.Duplicationof thispublicationorpartsthereofispermittedonlyundertheprovisionsoftheGermanCopyrightLaw ofSeptember9,1965,initscurrentversion,andpermissionforusemustalwaysbeobtainedfrom Springer.ViolationsareliableforprosecutionundertheGermanCopyrightLaw. SpringerisapartofSpringerScience+BusinessMedia springer.com ©Springer-VerlagBerlinHeidelberg2007 Theuseofgeneraldescriptivenames,registerednames,trademarks,etc.inthispublicationdoesnot imply,evenintheabsenceofaspecificstatement,thatsuchnamesareexemptfromtherelevantpro- tectivelawsandregulationsandthereforefreeforgeneraluse. Typesetting:ptp,Berlin Production:LE-TEXJelonek,Schmidt&VöcklerGbR,Leipzig Coverdesign:KünkelLopkaWerbeagentur,Heidelberg Printedonacid-freepaper 45/3100/YL-543210 ToCarmen,OscarandDaniel,ReginaandOscar... Past,PresentandFutur,alltogethermakingmeeasy tofacethefascinatingchallengeoflife OscarPastor ToBel´en,foreverything.Youenlightenmylife. Tomyparents,sistersandbrother,forbeingsowonderfulandsupportive. JuanCarlosMolina Toeverybody,pastandpresent,atCARETechnologiesandIntegranova. Youhaveturnedtheideasinthisbookintoasolidworkingreality. ToJose´MiguelBarbera´,forhisguidanceandcomradeship. ToSiegfriedBorho,forhisenduringvisionandspirit. JuanCarlosMolinaandOscarPastor Contents PartI TheOO-MethodandSoftwareProductionfromModels 1 Let’sGetPhilosophical.................................................. 3 2 ThePurposeofthisWork ............................................... 7 3 TheNeedforNewDevelopmentEnvironments.......................... 13 3.1 SoftwareDevelopmentToday ...................................... 14 3.1.1 CurrentToolsAreInadequate .............................. 14 3.1.2 DevelopmentProcessesAreNegativelyAffected............ 15 3.2 BetterDevelopmentEnvironmentsAreNeeded .................... 16 4 Object-OrientedModellingastheStartingPoint........................ 19 4.1 TheChosenModel................................................. 19 4.2 KeyAspectsoftheDesiredMethod ................................ 21 4.2.1 CataloguingofConceptualPatterns ........................ 22 4.2.2 EnrichingtheObjectModel................................ 28 4.2.3 SoftwareArchitecture:ArchitecturalPatterns .............. 32 5 TheOO-Method......................................................... 39 5.1 HistoricalBackground............................................. 39 5.2 GeneralFeaturesoftheOO-Method ............................... 42 5.3 OtherApproaches ................................................. 43 PartII ConceptualModelling:AbouttheProblemSpace 6 ConceptualModellingPrimitives ....................................... 49 6.1 ConceptualModelling.TheFourModels........................... 52 VIII Contents 7 ObjectModel............................................................ 55 7.1 Classes ............................................................ 55 7.1.1 Attributes.................................................. 58 7.1.2 Services.................................................... 62 7.1.3 IntegrityConstraints....................................... 73 7.2 RelationshipsBetweenClasses..................................... 75 7.2.1 AgentsandAgentRelationships ............................ 76 7.2.2 Association,Aggregation,andComposition ................ 80 7.2.3 Specialisation .............................................. 95 7.2.4 ParallelComposition....................................... 104 7.2.5 VisibilityBetweenRelatedClasses.......................... 106 7.3 ComplexityManagement .......................................... 111 8 DynamicModel......................................................... 115 8.1 StateTransitionDiagram .......................................... 116 8.1.1 States ...................................................... 117 8.1.2 Transitions................................................. 118 8.1.3 BasicStatechartDiagram .................................. 120 8.1.4 ManagingComplexityinStateTransitionDiagrams........ 121 8.1.5 OperationsandStateTransitionDiagrams ................. 122 8.1.6 SpecialisationandStateTransitionDiagrams............... 123 8.2 ObjectInteractionDiagram........................................ 124 8.2.1 Triggers.................................................... 125 8.2.2 GlobalTransactionsandGlobalOperations ................ 131 9 FunctionalModel ....................................................... 137 9.1 EventEffectSpecificationUsingEvaluations ....................... 139 9.2 EvaluationConditions ............................................. 139 9.3 CategorizationofEvaluations...................................... 141 9.4 CreationEventsandtheFunctionalModel......................... 142 9.5 DestructionEventsandtheFunctionalModel ..................... 144 9.6 SpecialisationandtheFunctionalModel........................... 144 9.7 Transactions,Operations,andtheFunctionalModel ............... 145 10 PresentationModel ..................................................... 147 10.1 GeneralStructure.................................................. 148 10.2 BasicElements..................................................... 151 10.2.1 Entry....................................................... 151 10.2.2 DefinedSelection .......................................... 153 10.2.3 ArgumentGrouping........................................ 155 10.2.4 ArgumentDependency..................................... 157 10.2.5 Filter....................................................... 159 10.2.6 OrderCriterion ............................................ 163 10.2.7 DisplaySet ................................................. 165 10.2.8 Navigation ................................................. 167 Contents IX 10.2.9 Actions..................................................... 169 10.3 InteractionUnits .................................................. 171 10.3.1 ServiceInteractionUnits................................... 172 10.3.2 InstanceInteractionUnit................................... 175 10.3.3 PopulationInteractionUnit ................................ 178 10.3.4 Master/DetailInteractionUnit ............................. 181 10.4 ActionHierarchyTree ............................................. 184 10.4.1 AgentsandActionHierarchyTrees......................... 187 10.5 ConstructingaPresentationModel ................................ 188 11 ConceptualModellingofLegacySystems ............................... 191 11.1 IntroductiontotheConceptofLegacyView ....................... 191 11.2 ObjectModel ...................................................... 192 11.2.1 LegacyViews............................................... 192 11.2.2 Relationships .............................................. 201 11.3 DynamicModel ................................................... 207 11.3.1 StateTransitionDiagrams.................................. 207 11.3.2 ObjectInteractionDiagrams ............................... 208 11.4 FunctionalModel.................................................. 208 11.5 PresentationModel................................................ 209 11.5.1 BasicElements............................................. 209 11.5.2 InteractionUnits........................................... 213 11.5.3 ActionHierarchyTree...................................... 213 12 ConceptualModelValidation ........................................... 215 12.1 Introduction....................................................... 215 12.2 ObjectModel ...................................................... 217 12.2.1 Classes..................................................... 217 12.2.2 RelationshipsBetweenClasses ............................. 221 12.3 DynamicModel ................................................... 223 12.3.1 StateTransitionDiagram................................... 223 12.3.2 ObjectInteractionDiagram ................................ 224 12.4 FunctionalModel.................................................. 224 12.4.1 Evaluations ................................................ 224 12.5 PresentationModel................................................ 225 12.5.1 BasicElements............................................. 225 12.5.2 InteractionUnits........................................... 229 12.5.3 ActionHierarchyTree...................................... 231 X Contents PartIII ConceptualModelCompilation:fromtheProblemSpacetotheSolution Space 13 TransformingModelsintoApplications................................. 235 14 RequirementsfortheCompilationofConceptualModels ............... 239 15 ApplicationExecutionStrategy ......................................... 241 15.1 SystemAccess ..................................................... 242 15.2 SystemView ....................................................... 242 15.3 SystemInteraction................................................. 243 15.3.1 ServiceExecution .......................................... 244 15.3.2 QueryExecution ........................................... 255 15.3.3 InteractionUnits........................................... 257 16 ApplicationArchitecture................................................ 261 17 TransformationStrategy ................................................ 265 17.1 Mappings.......................................................... 265 17.2 Transformations................................................... 266 18 BuildingaConceptualModelCompiler ................................. 269 19 IssueswithOtherApproaches........................................... 271 19.1 IssueswithModellingLanguages .................................. 271 19.1.1 LackofAdequacy .......................................... 271 19.1.2 ImpreciseSemantics ....................................... 274 19.1.3 StrongVersusWeakFormalisms............................ 274 19.1.4 LowAbstractionLevel...................................... 275 19.1.5 ActionSemantics........................................... 276 19.1.6 Formulae .................................................. 277 19.1.7 OverspecificationandRedundancy ........................ 277 19.2 IssueswithModelCompilation .................................... 278 19.2.1 LackofanApplicationExecutionStrategy ................. 278 19.2.2 IssueswithApplicationArchitectures ...................... 279 19.2.3 InsufficientTransformations............................... 279 19.3 StateoftheArt..................................................... 280 20 AnalogiesBetweenOO-MethodandMDA............................... 281 20.1 OO-MethodandMDA ............................................. 281 20.2 PropertiesofOO-MethodAbsentfromMDA ...................... 282 21 TheOO-MethodDevelopmentProcess .................................. 285 Contents XI 22 OO-MethodImplementations........................................... 289 22.1 OLIVANOVAModeler ............................................. 289 22.2 OLIVANOVATransformationEngines ............................. 290 Conclusions.................................................................. 293 References ................................................................... 295 Index......................................................................... 301 How this Book Is Organized Programming technologies have improved continuouslyduring the last decades but,fromanInformationSystemsperspective,somewell-knownproblemsassoci- atedwiththedesignandimplementationofanInformationSystemspersist:Object- Oriented Methods,Formal Specification Languages, Component-Based Software Production,Aspect-OrientedApproaches.Thisisonlyaveryshortlistoftechnolo- giesproposedtosolveaveryoldand,atthesametime,verywell-knownproblem: how to produce software of quality.Programming has been the key task during the last 40years,and the results have notbeen successfulyet.This bookwill ex- plore the need of facing a sound software production process from a different perspective:conceptualmodel-basedsoftwareproduction.Thereareseveralways torefertothatstrategy.Therearepeopledealingwiththenon-programmingper- spective where, by non-programming, we mean mainly modelling. Rather than ExtremeProgramming,theissueisthatanExtremeNon-Programming(Extreme Modelling-Oriented)approachshouldbetaken. OtherpeoplefocusonConceptualSchema-CentredSoftwareProduction,based ontheassumptionthat,todevelopanInformationSystem(IS),itisnecessaryand sufficienttodefineits Conceptual Schema.This ispresented in(Olive´2005)as a grandchallenge forInformationSystems Research.This bookisorientedtoface this challenge, providing concrete solutions.In particular, we will show how to achievetheobjectiveofgeneratingcodefromahigher-level systemspecification, normally represented as an Object-Oriented Conceptual Schema. Nowadays,the interestinMDAhasprovidedanewimpetusforallthesestrategies.Newmethods proposedifferenttypesofmodeltransformationsthatcoverallthedifferentsteps ofasoundsoftwareproductionprocessfromanInformationSystemsEngineering point of view.This must include Organizational Modelling,Requirements Engi- neering,ConceptualModellingandModel-BasedCodeGenerationtechniques.In thiscontext,itseemsthatthetimeofModel-TransformationTechnologiesisfinally here. Underthepushofthistechnologicalwave,andtakingadvantageofouryearsof experienceworkingonModel-DrivenDevelopment,wewilldefendthemainidea that,tohave a softwareproductofquality,the keyskill ismodelling;the issueis XIV Howthisbookisorganized that“themodelisthecode”(ratherthan“thecodebeingthemodel”).Considering this hypothesis, a sound Software Production Process should provide a precise setofmodels(representingthedifferentlevelsofabstractionofasystemdomain description),togetherwiththecorrespondingtransformationsfromahigherlevel of abstraction to the subsequent abstraction level.For instance,a Requirements Model should be properly transformed into its associated Conceptual Schema, andthisConceptualSchemashouldbeconvertedintothecorrespondingSoftware Representation(finalprogram). Assuming that, behind any programmer decision, there is always a concept, theproblemtobeproperlyfacedbyanyModel-TransformationTechnologyisthat of accurately identifying those concepts,together with their associated software representations.A precise definitionof the set of mappings between conceptual primitivesorconceptualpatternsandtheircorrespondingsoftwarerepresentations providesasolidbasisforbuildingConceptualModelCompilers. Thisiswhatwewish todointhisbook.Ourpreciseobjectiveistoshowhow anMDA-basedSoftwareProductionEnvironmentbasedonConceptualModelling canbeputintopractice.Todothis,threemaingoalsneedtobefulfilled.First,the mainconceptsinvolvedinsuchamethodmustbeproperlyintroduced.Second,how to constructan adequate Conceptual Modelhas tobe explained indetail.Third, the processof transformingthe source ConceptualModelintoitscorresponding SoftwareProductmustbeexplained.Inaccordancewiththesegoals,thestructure ofthisbookisdividedintothreeparts: • TheOO-MethodandSoftwareProductionfromModels • ConceptualModelling:AbouttheProblemSpace • ConceptualModelCompilation:fromtheProblemSpacetotheSolutionSpace Now it is time forthe reader to explore how to put all these ideas into practice, makingConceptualModel-DrivenDevelopmentanaffordabledream.