Top Banner
22 June 2010 Copyright © 2010 Data Access Technologies, Inc. A division of Data Access Technologies, Inc. Programming in UML: Why and How Ed Seidewitz
17

Programming in UML: Why and How

May 10, 2015

Download

Technology

Ed Seidewitz

Presentation given at the Symposium on Eclipse Open Source Software & OMG Open Specifications
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Programming in UML: Why and How

22 June 2010

Copyright © 2010 Data Access Technologies, Inc.

A division of Data Access Technologies, Inc.

Programming in UML: Why and How

Ed Seidewitz

Page 2: Programming in UML: Why and How

22 June 2010Page 2

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Developers provide feedback to the architects(maybe)

Modeling for Software Development

But…• It is hard to validate the correctness of the models before development.• The developers may not follow the models, without providing feedback.• It is hard to keep the models and development artifacts in sync during

development (and maintenance).

How it usually worksArchitects give models to developers

Developers create artifacts based on the models(maybe)

Architects create the models

Page 3: Programming in UML: Why and How

22 June 2010Page 3

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Modeling for Software Development

• Code-based development– Use models for initial design, but then focus on code– Pro: Code is single source of "truth"– Con: Code is not as good for expressing design as models

• Model-driven development– Use models as the source artifacts for development– Pro: Models can be more easily understood and evolved by human

developers and maintainers.– Con: Model must be detailed enough to be executable in its own right.

Two responses

But is this really a “con”??

Page 4: Programming in UML: Why and How

22 June 2010Page 4

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Executable UML: Perceived Issues

• Making models detailed enough for machine execution defeats the purpose of models for human communication.

• UML is not specified precisely enough to be executed (at least not in a standard way).

• Graphical modeling notations are not good for detailed programming.

Page 5: Programming in UML: Why and How

22 June 2010Page 5

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Executable UML: Issue Resolutions• Making models detailed enough for machine execution defeats the

purpose of models for human communication.– Executable models can still be more understandable than

executable code.– Non-executable models are still useful, too.

• UML is not specified precisely enough to be executed (at least not in a standard way).– The Foundational UML (fUML) standard specifies precise semantics

for an executable subset of UML.– Final adoption of fUML Version 1.0 by OMG Board of Directors is

expected soon.

• Graphical modeling notations are not good for detailed programming.– Concrete Syntax for a UML Action Language RFP requests a

standard textual action language with fUML semantics.– Action Language for fUML (Alf) submission in progress.

Page 6: Programming in UML: Why and How

22 June 2010Page 6

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

A virtual machine based on concurrent UML

activity flow semantics.

A virtual machine based on concurrent UML

activity flow semantics.

The target for “compiled”

models.

The target for “compiled”

models.

Architecture for Executable UML Tooling

fUML Execution Engine

Model Development Environment

Other Tools

Target Platform

Providing all the capabilities expected in a code-based IDE.

Providing all the capabilities expected in a code-based IDE.

In memory or via XMI transfer.

In memory or via XMI transfer.

Simulation, analysis,

optimization, etc.

Simulation, analysis,

optimization, etc.

Page 7: Programming in UML: Why and How

22 June 2010Page 7

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Modeling for Software Development

Architects validate the models by executing them in a simulated test environment

Technologists specify the implementation platform

The models are provisioned as executing artifacts on the target platform

Architects create the models

The models are the source code.

Using a standard-conforming UML

modeling tool

Using a standard-conforming UML

modeling tool

Using a standard-conforming UML

execution tool

Using a standard-conforming UML

execution tool

How it works with executable models

Page 8: Programming in UML: Why and How

22 June 2010Page 8

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

The models are validated in a development/test environment

Programming in UML

The models are deployed in a production environment

Developers create fully executable models

…is just programming, only better!

Developers iteratively execute, test and update the models

Page 9: Programming in UML: Why and How

22 June 2010Page 9

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Example: Property Management SOA

• Graphical UML notation for– Data model– Message model– Interface and class models– Component models

• Textual Alf notation for– Operation methods

Page 10: Programming in UML: Why and How

22 June 2010Page 10

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Property Data Model

Page 11: Programming in UML: Why and How

22 June 2010Page 11

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Service Request Message Model

Page 12: Programming in UML: Why and How

22 June 2010Page 12

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Service Reply Message Model

Page 13: Programming in UML: Why and How

22 June 2010Page 13

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Service Interface and Implementation

Page 14: Programming in UML: Why and How

22 June 2010Page 14

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Service Provider Component

Composite structure and ports are not in

fUML, but they can be interpreted per SoaML.

Composite structure and ports are not in

fUML, but they can be interpreted per SoaML.

Page 15: Programming in UML: Why and How

22 June 2010Page 15

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Operation method: establish

/** Establish a new property record. */activity establish ( in request: 'Property Record Establishment', out reply: 'Property Management Success Reply' [0..1], out error: 'Error Reply' [0..1] ) {

identifier = this.'property identifier factory'.'get next identifier'(); if (request.'property type' == 'Property Type'::personal) { property = new 'Personal Property'::'create property'(identifier,request.name); } else { property = new 'Real Property'::'create property'(identifier,request.name); }

reply = this.'create reply'(request.identifier, property);

}

/** Establish a new property record. */activity establish ( in request: 'Property Record Establishment', out reply: 'Property Management Success Reply' [0..1], out error: 'Error Reply' [0..1] ) {

identifier = this.'property identifier factory'.'get next identifier'(); if (request.'property type' == 'Property Type'::personal) { property = new 'Personal Property'::'create property'(identifier,request.name); } else { property = new 'Real Property'::'create property'(identifier,request.name); }

reply = this.'create reply'(request.identifier, property);

}

Operation methods are specified as UML activities.

Operation methods are specified as UML activities.

Newly created objects persist at the current

execution locus.

Newly created objects persist at the current

execution locus.

Names can have spaces or other

special characters.

Names can have spaces or other

special characters.

Page 16: Programming in UML: Why and How

22 June 2010Page 16

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

Operation method: update/** Update the data of a property other than acquisition or disposition. */activity update ( in request: 'Property Record Update', out reply: 'Property Management Success Reply' [0..1], out error: 'Error Reply' [0..1] ) {

property = Property -> select p (p.identifier == request.'property identifier'); if (property -> isEmpty()) { error = new 'Error Reply' ( identifier => request.identifier + "/error", 'request identifier' => request.identifier, 'error code' => "PRU-001", 'error message' => "Property not found." ); } else if (property.status == 'Property Type'::disposed) { … } else { if (request.'property location' -> notEmpty()) { location = Location -> select loc (loc.identifier == request.'property location'); 'Property Location'.createLink(property, location); } … }}

/** Update the data of a property other than acquisition or disposition. */activity update ( in request: 'Property Record Update', out reply: 'Property Management Success Reply' [0..1], out error: 'Error Reply' [0..1] ) {

property = Property -> select p (p.identifier == request.'property identifier'); if (property -> isEmpty()) { error = new 'Error Reply' ( identifier => request.identifier + "/error", 'request identifier' => request.identifier, 'error code' => "PRU-001", 'error message' => "Property not found." ); } else if (property.status == 'Property Type'::disposed) { … } else { if (request.'property location' -> notEmpty()) { location = Location -> select loc (loc.identifier == request.'property location'); 'Property Location'.createLink(property, location); } … }}

A “select” maps to a concurrent expansion

region over a class extent.

A “select” maps to a concurrent expansion

region over a class extent.

Creating a link automatically establishes a bidirectional relationship.

Creating a link automatically establishes a bidirectional relationship.

Page 17: Programming in UML: Why and How

22 June 2010Page 17

Copyright © 2010 Data Access Technologies, Inc.Model Driven Solutions

References

• Foundational UML (fUML)– Semantics of a Foundational Subset for Executable UML Models standard,

http://www.omg.org/spec/fuml – fUML Reference Implementation Project, http://www.modeldriven.org/fuml

• Action Language for fUML (Alf)– Concrete Syntax for a UML Action Language RFP,

http://www.omg.org/cgi-bin/doc?ad/2008-09-09 – Submission repository,

http://lib.modeldriven.org/MDLibrary/trunk/Applications/Alf-Reference-Implementation

• /doc – Latest submission document and current working draft• /dist – Parser for latest working version (currently v0.08)

• Contact– [email protected]– http://twitter.com/seidewitz