5

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

Carlos
  • 1,522
  • 5
  • 14
  • 26
Melisa
  • 157
  • 1
  • 9

1 Answers1

2

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
Community
  • 1
  • 1
xmojmr
  • 8,073
  • 5
  • 31
  • 54
  • thank you @xmojmr for kind help Yes this is exactly what I've meant but I didn't find examples in the link you have provided about code generation,validity checking and complexity metrics? – Melisa May 11 '14 at 14:56
  • 1
    @Melisa how UML tools support model-driven engineering by generating code etc. was somehow answered in your another question, e.g. here http://stackoverflow.com/a/23589385/2626313. For better answer you would have to specify more narrow question. There are many tools that support the MDA and use XMI metamodel to generate code, validate it and calculate various code metrics – xmojmr May 11 '14 at 15:07
  • Thank you @@xmojmr for the hints ,BTW,do you mean that the following: http://www.omg.org/spec/XMI/20110701/XMI-model.xmi is the semantic information of UML model elements? – Melisa May 11 '14 at 15:11
  • @Melisa I don't know what are your goals. Want to learn the subject. Want to write a paper on UML. Want to learn how to read UML diagrams. Want to learn how to do business analyst job... I have added a simple to try example through the GenMyModel web application to my answer. Hope it helps. (Starting by studying XMI abstract model technical specification is also possible but I don't know what are your goals :) – xmojmr May 11 '14 at 15:41
  • I can't thank you enough@xmojmr for guiding me,I just wanted to understand the subject and tried to imagine how the things done theoretically in UML(code generation,validity checking and complexity metrics ) and because I am new to this subject and I lost with a lot of variables in UML.Any hints or references about how these things done theoretically? – Melisa May 11 '14 at 18:47
  • @Melisa if you are more after the theoretical backgrounds then I'd recommend to visit the site of Conrad Bock (one of the UML designers) at http://www.conradbock.org/. As a programmer I found very useful his "UML 2.0 Activities and Actions" series published in "The Journal of Object Technology". Links are available from Conrad's site. Stack Overflow is oriented more on practical coding questions. You may find useful another Stack Exchange sites like http://cs.stackexchange.com/ or http://programmers.stackexchange.com/ – xmojmr May 11 '14 at 19:23