Executable and Translatable UML
Total Page:16
File Type:pdf, Size:1020Kb
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 Compiler Concepts How model compilers 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” implementation 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 diagrams 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 software 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 Modeling Language 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 software design 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 R3 notes : FreeformText open() 1 0..* 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 is actually billed as prepareStatement() Receive Payment 0..* applyPayment() Billing Clerk BillingRun dueDateReached() : Billing Clerk Issue Credit billingDate : Date noPaymentDue() billGroup() Use Case Diagram allBillsProduced() Class Diagram Collaboration Diagram C1 C2 Open Account prepareStatement( statementDate ) : Payment : Statement : Billing Clerk : Timer C3 Statement Prepared receivePayment( ) applyPayment( ) Pay Bill applyPayment( transaction ) noPaymentDue Component Diagram dueDateReached Paid On Payment No Payment dueDateReached( ) Time Past Due Due ignored Branch applyPayment( transaction ) Close Account HQ Paid Late Branch Activity Diagram State Diagram Sequence Diagram 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 profile 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 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 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 is actually billed as prepareStatement() 0..* applyPayment() BillingRun dueDateReached() billingDate : Date noPaymentDue() billGroup() allBillsProduced() Information Model (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 R3 notes : FreeformText open() 1 0..* 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 : Payment is actually billed as prepareStatement() 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