<<

Executable and Translatable UML

Stephen J. Mellor Marc J. Balcer Contents

ƒ What’s the problem? ƒ UML Models ƒ Executable UML elements ƒ Executable UML behavior ƒ The Repository ƒ Model Concepts ƒ How model work ƒ MDA

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 2 What’s the Problem?

Analysts create …print them out… … then the developers “high-level” look at the models application and write the models… production code

These models are Coding adds this independent of the “design detail” technology

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 3 What’s the Problem?

But once …we shouldn’t something is in have to manually a machine reinterpret it representation… (“elaborate it”) into another.

The analyst’s Keeping the diagrams The rework introduces don’t have to be complete, in sync with the code development errors and correct, or consistent models is a daunting task. obscures analyst errors

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 4 What’s the Problem?

But once …we shouldn’t something is in Because have to manually a machine elaboration reinterpret it representation… (“elaborate it”) is stupid! into another.

The Ant appears courtesy of Leon Starr, Executable UML

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 5 Executable Models

Analysts • create executable models • test those executable models

…and compile the models to produce a running system

Developers • buy, build, or adapt a model compiler for a architecture • map model elements to the architecture…

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 6 Executable Models

The analyst’s models must be complete, correct, and consistent— and the models are verifiable.

The process always moves forward…

…there’s no editing of the translated code, no round-tripping, no reverse-engineering, no getting out of sync.

The software deign decisions are formalized in the mappings and translation archetypes

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 7 Contents

ƒ What’s the problem? ƒ UML Models ƒ Executable UML elements ƒ Executable UML behavior ƒ The Repository ƒ Model Compiler Concepts ƒ How model compilers work ƒ MDA

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 8 What’s UML?

“The Unified is a language for specifying, constructing, visualizing, and documenting artifacts of a software-intensive system” —The UML Summary ®

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 9 What’s UML?

ƒ Common notation for OOA / OOD ƒ Goal was to eliminate the notation wars ƒ One notation for many purposes ƒ Very large ® ƒ Concept of “profiles” for different uses

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 10 UML in Practice

Describing Modeling Documenting a problem a solution software “Requirements” “Analysis” “Design”

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 11 UML in Practice

Just because these use the same notation (UML) doesn’t mean these are the same problem.

The does not follow from the model of the The models are more than problem just the observable behavior to the user

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 12 Notation Semantics

doBilling( ) : BillingGroup Customer name : PersonalName Open Account address : MailingAddress phone : TelephoneNumber billGroup( ) customerID : CustomerIDNumber : Timer billingComplete( )

is the responsibility of 1 R1 : BillingRun is responsible for 1..* Suspend Account Account Customer Service Collection Agent number : CardAccountNumber Rep / currentBalance : Money Call Delinquent Customer actualCreditLimit : Money Transaction requestedCreditLimit : Money is processed prepareStatement( ) transactionDate : Date interestRate : Percent on accumulates / netAmount : Money 1 R3 0..* notes : FreeformText open() dueDateReached( ) suspend( ) approve() reinstate( ) Close Account suspend() is current presents 0..* presentation of : Statement : Account reinstate() R12 close() 1 directs billing of 0..* Produce Bills for Group R5 Timer R2 is billed as part of 1 BillingGroup applyPayment( ) groupNumber : BillingGroupNumber is currently billingDay : BillingDayNumber Submit Charge presented to 1 customer as 0..1 appears on receivePayment( ) doBilling() Statement billingComplete() / statementDate : Date : Payment is an actual billing of 1 minimumAmountDue : Money Merchant paymentDueDate : Date R4 prepareStatement() is actually billed as 0..* Receive Payment applyPayment() Billing Clerk BillingRun dueDateReached() : Billing Clerk Issue Credit billingDate : Date noPaymentDue()

billGroup() allBillsProduced() Collaboration Diagram C1 C2 Open Account prepareStatement( statementDate ) : Payment : Statement : Billing Clerk : Timer C3 Statement Prepared

receivePayment( ) applyPayment( ) Pay Bill applyPayment( transaction ) noPaymentDue dueDateReached Paid On Payment No Payment dueDateReached( ) Time Past Due Due ignored Branch applyPayment( transaction ) Close Account HQ Paid Late

Branch Remote

Deployment Diagram Each diagram is well-defined, but how do they fit together?

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 13 Contents

ƒ What’s the problem? ƒ UML Models ƒ Executable UML elements ƒ Executable UML behavior ƒ The Repository ƒ Model Compiler Concepts ƒ How model compilers work ƒ MDA

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 14 UML in Practice O u r F oc us

Describing Modeling Documenting a problem a solution software “Requirements” “Analysis” “Design”

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 15 UML Profiles

Customer name : PersonalName address : MailingAddress phone : TelephoneNumber customerID : CustomerIDNumber

is the responsibility of 1 R1 is responsible for 1..* A defines how these Account number : CardAccountNumber / currentBalance : Money actualCreditLimit : Money Transaction requestedCreditLimit : Money is processed transactionDate : Date interestRate : Percent on accumulates / netAmount : Money diagrams represent models 1 R3 0..* notes : FreeformText open() approve() suspend() is current presents 0..* presentation of reinstate() R12 close() 1 directs billing of 0..* R2 R5 is billed as part of 1 BillingGroup groupNumber : BillingGroupNumber is currently billingDay : BillingDayNumber presented to 1 customer as 0..1 appears on doBilling() Statement billingComplete() / statementDate : Date is an actual billing of 1 minimumAmountDue : Money paymentDueDate : Date R4 prepareStatement() is actually billed as 0..* applyPayment() BillingRun dueDateReached() billingDate : Date noPaymentDue()

billGroup() allBillsProduced() (things in the problem and how they are related) prepareStatement( statementDate )

Statement Prepared

applyPayment( transaction ) noPaymentDue dueDateReached

Paid On Payment No Payment Time Past Due Due

applyPayment( transaction )

Paid Late

State Model (lifecycle of an instance of a class)

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 16 UML Profiles

Customer doBilling( ) name : PersonalName address : MailingAddress : BillingGroup phone : TelephoneNumber customerID : CustomerIDNumber

1 is the responsibility of billGroup( ) R1 : Timer billingComplete( ) is responsible for 1..* It also defines a set of diagrams Account number : CardAccountNumber : BillingRun / currentBalance : Money actualCreditLimit : Money Transaction requestedCreditLimit : Money is processed transactionDate : Date interestRate : Percent on accumulates / netAmount : Money that are derived from 1 R3 0..* notes : FreeformText open() approve() prepareStatement( ) suspend() is current presents 0..* presentation of reinstate() R12 dueDateReached( ) close() 1 suspend( ) directs billing of 0..* the basic models reinstate( ) : Statement : Account R2 R5 is billed as part of 1 BillingGroup groupNumber : BillingGroupNumber is currently billingDay : BillingDayNumber presented to 1 customer as 0..1 appears on applyPayment( ) doBilling() Statement billingComplete() / statementDate : Date is an actual billing of 1 minimumAmountDue : Money receivePayment( ) paymentDueDate : Date R4 prepareStatement() : Payment is actually billed as 0..* applyPayment() BillingRun dueDateReached() billingDate : Date noPaymentDue() billGroup() : Billing Clerk allBillsProduced() Information Model Object Communication Model (things in the problem (summary of object interactions) and how they are related) prepareStatement( statementDate )

Statement Prepared

: Payment : Statement applyPayment( transaction ) noPaymentDue : Billing Clerk : Timer dueDateReached receivePayment( ) Paid On Payment No Payment applyPayment( ) Time Past Due Due

applyPayment( transaction ) dueDateReached( ) Paid Late ignored State Model (lifecycle of an instance of a class) Execution Trace (system behavior under one scenario)

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 17 Classes

Customer Class name : PersonalName address : MailingAddress phone : TelephoneNumber abstraction of common characteristics customerID : CustomerIDNumber

is the responsibility of 1 and common behavior R1 is responsible for 1..* Account number : CardAccountNumber Attribute / currentBalance : Money actualCreditLimit : Money Transaction requestedCreditLimit : Money is processed transactionDate : Date abstraction of a single interestRate : Percent on accumulates / netAmount : Money R3 notes : FreeformText open() 1 0..* characteristic of a class approve() suspend() is current presents 0..* presentation of reinstate() R12 close() 1 directs billing of 0..* derived attribute R2 R5 is billed as part of 1 BillingGroup groupNumber : BillingGroupNumber is currently billingDay : BillingDayNumber presented to 1 customer as 0..1 appears on doBilling() Statement billingComplete() / statementDate : Date is an actual billing of 1 minimumAmountDue : Money Association paymentDueDate : Date R4 prepareStatement() is actually billed as 0..* abstraction of a relationship applyPayment() BillingRun dueDateReached() billingDate : Date noPaymentDue() between classes

billGroup() allBillsProduced() Event association class received by the object’s state machine

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 18 Lifecycles

Statement initial pseudostate

prepareStatement( statementDate )

Statement Prepared State a stage in the lifecycle applyPayment( transaction ) noPaymentDue dueDateReached

Paid On Payment No Payment Time Past Due Due Event applyPayment( transaction ) abstraction of a single Paid Late signal received by the state machine Transition abstraction of a progression from state to state

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 19 State Procedure & Actions

Each state has a procedure executed upon entry to the state

prepareStatement( statementDate ) Statement Prepared Statement Prepared

applyPayment( transaction ) noPaymentDue dueDateReached ?

Paid On Payment No Payment Time Past Due Due

applyPayment( transaction )

Paid Late

Actions specify what happens in the state procedure

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 20 Expressing Actions

ƒ Need to express the semantics of the

Statement Prepared problem domain - in pseudocode ? - in Java itself? - in a Java-esque syntax? - in a ? - in a dataflow diagram? - in pipes-and-filters?

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 21 Why not pseudocode?

in the world or belonging to this customer?

Statement Prepared how do we know? entry/ for each transaction not yet billed post that transaction to the statement

“the statement” what does “post” mean? You talkin’ to me? You wanna post that transaction to me?

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 22 Why not 3GL code?

Statement Prepared ƒ Binds the model to a entry/ particular query = “SELECT * FROM TBL_TRANS, … implementation set rst=CurrentDB().open(query) while not rst.EOF rst.Edit rst(“R5StatementPtr”) = statementID ƒ Requires other rst.Update non-application rst.MoveNext wend decisions to be made rst.Close at the same time (Microsoft Visual Basic…sort of)

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 23 What to do about actions?

ƒ Pseudocode is not executable

Statement Prepared ƒ 3GLs bind model to a particular architecture ? ƒ We want to write - from a problem perspective - in terms of the model - not presuming a specific implementation

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 24 What about actions?

ƒ UML (pre – 1.5) did not have a formalism for actions Statement Prepared ƒ Precise Action Semantics specification ? supplements the UML - functional/dataflow- based - established the executable profile - essential for executability

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 25 UML Action Semantics

ƒ Integrated into UML 1.5 ƒ Fundamental actions on UML elements (classes, associations, …) ƒ Foundations for writing Precise Action Semantics for UML processing in an executable model - in the problem domain - does not presume an implementation

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 26 Semantics, not Language

ƒ Why not just design an action language? - Highly political Language Language Language A B C - Many vendors had some proprietary (but not fully compliant) action languages. Uniform Action Semantics - Syntax issues would obscure semantic issues ƒ First define a uniform semantics

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 27 Action Languages

TALL ƒ Several different foreach transaction in self->Account->Transaction[not .isBilled] tool-specific languages self->Transaction := transaction; endfor; ƒ First step is to make all action-semantics compliant OAL ƒ Syntax is secondary foreach transaction related by self->Account[R12]->Transaction[R3] where not selected.isBilled relate transaction to self across R5; end for;

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 28 Actions

ƒ Specify the logic for each state’s action.

Statement Prepared

entry/ Statement Prepared foreach transaction related by self->Account[R12]->Transaction[R3] where not selected.isBilled relate transaction to self across R5; end for;

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 29 Actions – Other Uses

Account number : CardAccountNumber {I} / currentBalance : Money actualCreditLimit : Money requestedCreditLimit : Money interestRate : Percent

open() approve() suspend() reinstate() currentBalance = 0; close() foreach transaction related by self->Transaction[R3] select many accounts from instances of Account currentBalance = currentBalance + where selected.number == self.number; transaction.netAmount; return ((cardinality accounts) == 1); end for;

Derived Attribute Constraint

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 30 An Executable Model

Customer name : PersonalName address : MailingAddress phone : TelephoneNumber customerID : CustomerIDNumber

is the responsibility of 1 R1 is responsible for 1..* Account number : CardAccountNumber / currentBalance : Money actualCreditLimit : Money Transaction requestedCreditLimit : Money is processed transactionDate : Date interestRate : Percent on accumulates / netAmount : Money R3 notes : FreeformText open() 1 0..* approve() suspend() is current presents 0..* presentation of reinstate() R12 close() 1 directs billing of 0..* R2 R5 is billed as part of 1 prepareStatement( statementDate ) BillingGroup groupNumber : BillingGroupNumber is currently billingDay : BillingDayNumber Statement Prepared presented to 1 Statement Prepared customer as 0..1 appears on doBilling() Statement billingComplete() / statementDate : Date is an actual billing of 1 minimumAmountDue : Money paymentDueDate : Date entry/ R4 noPaymentDue prepareStatement() applyPayment( transaction ) is actually billed as 0..* applyPayment() BillingRun dueDateReached() dueDateReached foreach transaction related by billingDate : Date noPaymentDue() Paid On Payment No Payment self->Account[R12]->Transaction[R3] billGroup() Past Due Due allBillsProduced() Time where not selected.isBilled applyPayment( transaction ) relate transaction to self across R5; Classes Paid Late end for;

Lifecycle of Statement Statement Prepared state procedure

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 31 Table of contents

ƒ What’s the problem? ƒ UML models ƒ Executable UML elements ƒ Executable UML behavior ƒ The repository ƒ Model compiler concepts ƒ How model compilers work ƒ MDA

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 32 Instances

An executable model operates on instances.

Account number : CardAccountNumber number currentBalance actualCredit requestedCredit interestRate / currentBalance : Money Limit Limit actualCreditLimit : Money requestedCreditLimit : Money interestRate : Percent 231552343 110.23 5000 5000 14%

open() 897899934 0.00 8000 10000 12% approve() suspend() 789978994 3423.32 3500 5000 18% reinstate() close()

Statement statementDate minimumAmountDue paymentDueDate / statementDate : Date minimumAmountDue : Money 5/10/2003 10.00 6/1/2003 paymentDueDate : Date

prepareStatement() 6/1/2003 0.00 6/21/2003 applyPayment() dueDateReached() 6/2/2003 68.00 6/21/2003 noPaymentDue()

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 33 Instances

An executable model operates on instances.

Statement / statementDate : Date prepareStatement( statementDate ) minimumAmountDue : Money paymentDueDate : Date Statement Prepared prepareStatement() applyPayment() dueDateReached dueDateReached() applyPayment( transaction ) noPaymentDue noPaymentDue()

Paid On Payment No Payment Time Past Due Due prepareStatement( statementDate )

a pplyPaym ent ( tr ansa ction ) Statement Prepared

Paid Late

dueDateReached prepareStatement( statementDate ) applyPayment( transaction ) noPaymentDue Statement Prepared Paid On Payment No Payment statement A Time Past Due Due

a pplyPaym ent ( tr ansa ction ) dueDateReached applyPayment( transaction ) noPaymentDue Paid Late Paid On Payment No Payment Time Past Due Due statement B applyPayment( transaction ) Paid Late

statement C

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 34 Execution

prepareStatement( statementDate ) ƒ The lifecycle model Statement Prepared prescribes execution dueDateReached applyPay ment ( tr ans action ) noPaymentDue

Paid On Payment No Payment Time Past Due Due applyPayment( transaction ) When the customer’s payment is Paid Late received, the statement transitions to the next statement and executes actions.

prepareStatement( statementDate )

Statement Prepared

dueDateReached applyPay ment ( tr ans action ) noPaymentDue

Paid On Payment No Payment Time Past Due Due

applyPayment( transaction )

Paid Late

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 35 Executing the Model

ƒ The model executes in response to signals from: - the outside, prepareStatement( statementDate ) Statement Prepared

- timers applyPayment( transaction ) noPaymentDue (delayed events) dueDateReached

Paid On Payment No Payment Time Past Due Due - other instances as they execute applyPayment( transaction ) Paid Late

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 36 Concurrent Execution

All instances execute concurrently.

Statement / statementDate : Date prepareStatement( statementDate ) minimumAmountDue : Money paymentDueDate : Date Statement Prepared prepareStatement() applyPayment() dueDateReached dueDateReached() applyPayment( transaction ) noPaymentDue noPaymentDue()

Paid On Payment No Payment Time Past Due Due prepareStatement( statementDate )

a pplyPaym ent ( tr ansa ction ) Statement Prepared

Paid Late

dueDateReached prepareStatement( statementDate ) applyPayment( transaction ) noPaymentDue Statement Prepared Paid On Payment No Payment statement A Time Past Due Due

a pplyPaym ent ( tr ansa ction ) dueDateReached applyPayment( transaction ) noPaymentDue Paid Late Paid On Payment No Payment Time Past Due Due statement B applyPayment( transaction ) Paid Late

statement C

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 37 Communication

prepareStatement( statementDate )

Statement Prepared receivePayment( accountNumber, date, amount )

Received dueDateReached applyPay ment ( tr ans action ) noPaymentDue

Paid On Payment No Payment Time Past Due Due checkCleared a pplyPaym ent ( tr ansa ction )

Accepted before Paid Late

prepareStatement( statementDate )

Statement Prepared

dueDateReached applyPay ment ( tr ans action ) noPaymentDue

Paid On Payment No Payment Time Past Due Due

applyPayment( transaction ) after Paid Late

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 38 Concurrent Execution

Multiple events may be received.

prepareStatement( statementDate )

Statement Prepared receivePayment( accountNumber, date, amount )

Billing Clerk Received dueDateReached applyPay ment ( tr ans action ) noPaymentDue

Paid On Payment No Payment Time Past Due Due checkCleared a pplyPaym ent ( tr ansa ction )

Accepted Paid Late

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 39 Concurrent Execution

ƒ Concurrent events can produce different outcomes

: Payment : Statement : Account : Billing Clerk : Timer

: Payment : Statement : Account : Billing Clerk : Timer dueDateReached( ) suspend( )

receivePayment( ) applyPayment( )

receivePayment( ) applyPayment( ) dueDateReached( ) reinstate( )

ignored

Two outcomes if the payment is received as the due date passes

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 40 Verification

ƒ Test models in the development environment ƒ Check the models just like code

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 41 Table of contents

ƒ What’s the problem? ƒ UML models ƒ Executable UML elements ƒ Executable UML behavior ƒ The repository ƒ Model compiler concepts ƒ How model compilers work ƒ MDA

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 42 Model Repository

ƒ Compilation requires that the models be available in a metamodel-based model repository Model Repository

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 43 Model Repository

ƒ The repository holds the developers’ models.

Customer name : PersonalName address : MailingAddress phone : TelephoneNumber prepareStatement( statementDate ) customerID : CustomerIDNumber

is the responsibility of 1 Statement Prepared R1 is responsible for 1..* Account number : CardAccountNumber noPaymentDue / currentBalance : Money applyPayment( transaction ) actualCreditLimit : Money Transaction requestedCreditLimit : Money is processed dueDateReached transactionDate : Date interestRate : Percent on accumulates / netAmount : Money 1 R3 0..*notes : FreeformText No Payment open() Paid On Payment approve() Time Past Due Due suspend() is current presents 0..* presentation of reinstate() R12 close() 1 directs billing of 0..* applyPayment( transaction ) R2 R5 Statement Prepared is billed as part of 1 Paid Late BillingGroup groupNumber : BillingGroupNumber is currently billingDay : BillingDayNumber presented to 1 customer as 0..1 appears on doBilling() Statement entry/ billingComplete() / statementDate : Date is an actual billing of 1 minimumAmountDue : Money paymentDueDate : Date foreach transaction related by R4 prepareStatement() is actually billed as 0..* applyPayment() self->Account[R12]->Transaction[R3] BillingRun dueDateReached() billingDate : Date noPaymentDue() where not selected.isBilled billGroup() allBillsProduced() relate transaction to self across R5; end for; Model Repository

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 44 Metamodel

<> Domain {1,Domain} <> AssociationConstraint name : string {I} {308,AssociationConst} description : DescriptionString OOA * 1 1 instances are subject to belongs belongs to to of R124 AssociationEnd R121 {109,AssociationEnd}

* defines 1 restricts values of associationNumber : integer{I,I2,R110} classNumber : integer {I,R110} OOA Association phrase : string {I2} {108,Association} multiplicity : integer associationNumber : integer {I} * R110 1 name : string {I2} participates formalizes description : DescriptionString in

R109 is formalized 0,1 by AbstractClass {112,AbstractClass}1R119 1..* Generalization AssociationClass 1..* relates {106,Generalization} {115,AssociationClass} classNumber : integer{I,R118} superclass is Class must be subclassed discriminator : string {I} R111 R118 isComplete : boolean 0,1R125 1 {101,Class} according to is is classNumber : integer {I} ConcreteClass name : string {I2} {disjoint, {113,ConcreteClass} abbreviation : string {I3} complete} * description : DescriptionString classNumber : integer{I,R118} * is a specialization of defines Transformer *1R122 {114,Transformer} 1..* R115 is synchronously name : string synchronously modifies subclasses are modified by 1 1 restricts values of is a Specialization characteristic {107,Specialization} of <> R123 R103 ClassConstraint * {307,ClassConstraint} instances are subject to characteristics are * abstracted as <> Attribute Datatype {102,Attribute} {2,Datatype} name : string R102 name : string {I} description : DescriptionString * 1 description : DescriptionString defines is of type type of

1 return type is R104 {disjoint, complete} R120 = R105+R104+R102 * defines return type of BaseAttribute DerivedAttribute AttributeFormula {103,BaseAttribute} {104,DerivedAttribute} {105,AttributeFormula}

11R105 computes value is value of computed by

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 45 Metamodel Instances

ƒ Just like an application model, the metamodel has instances.

classID name description

100 Customer A Customer is any individual or business… 101 Account An account represents a customer’s financial… 102 BillingGroup A set of accounts that are all billed periodically…

classID stateID stateName

101 1 NewAccount

101 2 In Good Standing

101 3 Suspended

101 4 Closed

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 46 Repository Instances

ƒ Modeling tools create instances in the repository

classID name description

100 Customer A Customer is any individual or business… 101 Account An account represents a customer’s financial… 102 BillingGroup A set of accounts that are all billed periodically… 103 Statement A statement is a periodic preparation of the …

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 47 Table of contents

ƒ What’s the problem? ƒ UML models ƒ Executable UML elements ƒ Executable UML behavior ƒ The repository ƒ Model compiler concepts ƒ How model compilers work ƒ MDA

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 48 Model Compiler

A model compiler is the automated embodiment of how to turn a model into software under a set of rules.

Analysts create models

Model Compiler produces a running system

Developers program the rules

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 49 Model Compiler

…a program that creates code from models…

Analysts create models

Model Compiler produces a running system

Developers program the rules

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 50 Model Compiler

…something that makes models executable…

Analysts create models

Model Compiler produces a running system

Developers program the rules

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 51 Model Compiler

…it’s a model compiler.

Analysts create models

Model Compiler produces a running system

Developers program the rules

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 52 The Big Picture

politically Libraries, Legacy, incorrect and Hand-Written cartoon Code

Executable Models

Generator Software System

Archetypes and Mappings Execution Engine Model Compiler © 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 53 Model Compiler

Concurrency and ƒ A model compiler reads sequentialization Multi-processing executable UML models and multi-tasking and creates a system with certain dimensions

Persistence

Data structuring organization

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 54 Examples

Financial system • Highly distributed • Concurrent • Transaction-safe with rollback • Persistence with rollback • J2EE (Java + EJB) Embedded system • Single task • No operating system • Optimized data access and storage •C Telecommunication system Simulation system • Highly distributed • Mostly synchronous • Asynchronous •Few tasks • Limited persistence • Special-purpose capability language “Import” •C++

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 55 Table of contents

ƒ What’s the problem? ƒ UML models ƒ Executable UML elements ƒ Executable UML behavior ƒ The repository ƒ Model compiler concepts ƒ How model compilers work ƒ MDA

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 56 The Big Picture

Libraries, Legacy, and Hand-Written Code

Executable Models

Generator Software System

Archetypes and Mappings Execution Engine Model Compiler © 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 57 Model Compiler

.Function Class Class ${Class.name} : public ActiveInstance { private: .invoke PrivateDataMember( Class ) .Function PrivateDataMember .param Class Class }; .select many PDM from instances of Attribute related to Class .for each PrivateDataMember ${PDM.Type} ${PDM.Name}; .endfor

Archetypes Execution Engine Translation rules interpreted by a A limited set of reusable generator against the repository components sufficient to execute Executable UML

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 58 Archetypes

Archetypes traverse the repository and... classID name description 100 Customer A Customer is any individual or business…

101 Account An account representsclassID a customer’sstateID financial… stateName 102 BillingGroup A set of accounts that are all billed periodically… 101 1 NewAccount 101 2 In Good Standing 101 3 Suspended 101 4 Closed

… output text.

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 59 Archetypes

ƒ Archetypes direct the generation of text. Placeholder introduced by ${...}

.Function Class text (which happens Class ${Class.name} : to be C++) public ActiveInstance { private: .invoke PrivateDataMember( Class ) .Function PrivateDataMember .param Class Class }; .select many PDM from instances of Attribute related to Class .for each PrivateDataMember ${PDM.Type} ${PDM.Name}; .endfor

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 60 Example

ƒ The archetype language produces text. .select many stateS related to instances of class->[R13]StateChart ->[R14]State where (isFinal == False) public: public: enum states_e enum states_e { NO_STATE = 0 , { NO_STATE = 0 , .for each state in stateS NewAccount , InGoodStanding , .if ( not last stateS ) Suspended , ${state.Name } , NUM_STATES = Closed .else }; NUM_STATES = ${state.Name} .endif .endfor };

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 61 Mappings

ƒ Design-time assignment of different archetypes to distinct elements in the model

ƒ Separate from the model and the archetypes

ƒ “Uniformity != Rigidity”

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 62 Table of contents

ƒ What’s the problem? ƒ UML models ƒ Executable UML elements ƒ Executable UML behavior ƒ The repository ƒ Model compilers ƒ Model compiler concepts ƒ How model compilers work ƒ MDA

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 63 Model Driven Architecture

ƒ A standard for using formal, executable and compilable system specifications ƒ Standards should be based on executable UML including the Action Semantics. ƒ Interchange can be managed using XML

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 64 Executable UML

ƒEntry tools: BridgePoint®, Rose®, others ƒVerification tools: T-Vec®, S/R®, COSPAN®

A B C D

Exec. UML Common Semantics XML

P Q R S

Model Compilers turn Executable UML models into systems.

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 65 Building a Market

ƒ Design time composability - protects IP

The models are a valuable corporate resource that are true business models— they describe the business, not the software.

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 66 Building a Market

ƒ Design time composability - protects IP - allows IP to be mapped to multiple

Just because we move to a new software platform doesn’t mean that we need to recreate the rules of the bank.

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 67 Building a Market

ƒ Design time composability - protects IP - allows IP to be mapped to multiple implementations - enables a market in IP in software We can sell “Billing” models that can run on many platforms and support many different businesses.

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 68 The Future

ƒ Executable UML enables a market in model compilers.

ƒ Application experts build models…. - ….select the appropriate model compiler, and… - ….compile the model.

ƒ Each model compiler targets a specific software platform.

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 69 Conclusion

ƒ Executable UML, using archetypes to direct the generation, enables: - early error detection through verification - reuse of the execution engine - faster performance tuning - faster integration - faster, cheaper retargeting

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 70 Brought to you by…

© 2003 Stephen J. Mellor and Marc J. Balcer All Rights Reserved 71