Chapter 7. Class Actions


The declaration of a class on a class diagram doesn't "do" anything; the declaration merely states that when we create instances of the class, each object must have the data and behavior declared by the class.

Actions do stuff: They create and delete objects, access attributes and links, make conditional choices, iterate, transform data, and otherwise generally compute. In the course of this book, we shall describe the actions you can specify that make the domain actually do something. In this chapter, we'll describe those actions that affect objects, links, and classes.

Executable UML relies on the Precise Action Semantics for UML [1] adopted as an integral part of UML in late 2001. These action semantics provide for the specification of actions, but they do not define an action language syntax.

Presently, therefore, there is no standard syntax for actions, though to specify the actions in an executable model, we have to use something, some concrete syntax. The syntax we use here is a real one, and it executes today [2]. The complete case study models for the online bookstore have been executed using this language, and the case study models are presented in Appendix B.

Why NotJava?

Why not just write Java? Or just use your favorite programming language?

The answer has to do with raising the level of abstraction. To gain access to higher-level abstractions such as data structures and control structures, we gave up the ability to manipulate registers and the stack directly. This conferred independence from the hardware platform, in turn enabling portability of programs from one hardware platform to another.

So it is with Executable UML and the action language. In return for the ability to work in terms of the domain objects directly, you give up pointer manipulation, arrays, lists, and various implementation tricks your language allows. This grants independence from the software platform. Now you can build Executable UML models and have them execute on a distributed system using CORBA, a small footprint embedded chip using C and no operating system, or a complex multi-processor implementation using C++ all without having to change the application models.

To garner these benefits, the action semantics:

  • defines statements that are by default concurrent, so that statements that do not share common data can run concurrently.

  • defines functional computations separately from the data access logic, so that functional computation does not need to be respecified when a model compiler changes the data structures.

  • allows direct manipulation of UML elements only, so that model compilers can safely assume their own rules are not violated.

The action semantics does not specify software structure anywhere. There are no mechanisms to denote persistence, or the manner of an invocation, or distribution, or how data is stored. All this is properly the business of the model compiler.

An Executable UML model specifies the minimum required to show how a domain works in the context of the problem, and that's all.

These requirements, and others, are discussed in detail in Software-Platform-Independent, Precise Action Specifications for UML [3].

But this chapter is not about syntax. Accordingly, this chapter does not describe every syntactic element of the language we use (if statements and loops, for example), nor does it describe every syntactic nitty-gritty detail.

graphics/exclamation.gif

To describe syntax, we use conventional syntax description forms, such as <class>, and we use the following typographical conventions for representing action language:

Boldfaced words are keywords or reserved words.

Capitalized Italics are class names.

Lowercase italics are object references or attributes.

For example:


select any objectRef from instances of Class
where selected.className == "my Class";
// Comments may appear anywhere;
// we show them below the action fragment

To define a language is not difficult. Given the standard definition of the semantics that is provided by the action semantics, you could design your own favorite syntax. To illustrate this point, we present two other action languages in Section 7.6: Other Action Languages.



Executable UML. A Foundation for Model-Driven Architecture
Executable UML: A Foundation for Model-Driven Architecture
ISBN: 0201748045
EAN: 2147483647
Year: 2001
Pages: 161

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net