How the semantics aspect of UML model can be used in code generation, validity checking and complexity metrics?

StackOverflow https://stackoverflow.com/questions/20718452

Domanda

I've found the definition of model in UML reference manual (chapter 2) and I can't get what the authors mean by the following sentence:

The semantic modeling elements are used for code generation, validity checking, complexity metrics.

How can the semantic aspect of UML model be used in

1) code generation,

2) validity checking and

3) complexity metrics

I hope I can find someone help me understand it through simple example

È stato utile?

Soluzione

If you are referring to book "The Unified Modeling Language Reference Manual" by James Rumbaugh, Ivar Jacobson, Grady Booch, Copyright © 1999 by Addison Wesley Longman, Inc. then the part you are quoting from chapter 2 starts with

What Is in a Model?

Semantics and presentation. Models have two major aspects: semantic information (semantics) and visual presentation (notation). The semantic aspect captures the meaning of an application as a network of logical constructs, such as classes, associations, states, use cases, and messages. Semantic model elements carry the meaning of the model - that is, they convey the semantics. The semantic modeling elements are used for code generation, validity checking, complexity metrics, and so on. The visual appearance is irrelevant to most tools that process models...

So there is an invisible semantic model, database of things, usually represented as file in XML Metadata Interchange (XMI) format. This database is used for generation of code and everything. Many modeling tools support import/export of models in this format. At the time the book was written XMI even did not support importing/exporting diagrams (pictures, the visual presentation), only the semantic part of the models.

On the other hand there are "only pictures" shown as UML diagrams that display various aspects of the model. But they are only pictures to be read by humans with no value for machines.

See e.g. this https://stackoverflow.com/a/23308423/2626313 for an example. The right-lower corner shows what is in the model, the other things are "only pictures"

EDIT: for hands-on experience evaluate some tool that can do the code generation and take a look at what it does.

Professional tool that can do/explain a lot is Sparx Systems Enterprise Architect with some community of users available here on Stack Overflow.

An easy to get started way using some more light-weight tool:

  1. open the link in Stack Overflow answer https://stackoverflow.com/a/22694685/2626313 leading to the GenMyModel website
  2. in the GenMyModel application click "Tools → Direct Generation → Java". Download and explore the generated code
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top