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

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

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:
open the link in Stack Overflow answer https://stackoverflow.com/a/22694685/2626313 leading to the GenMyModel website
in the GenMyModel application click "Tools → Direct Generation → Java". Download and explore the generated code

Related

How to use an activity diagram to detail classes & methods?

I wish to document code for a fairly complex algorithm whose implementation is intertwined across several methods and classes. A sequence diagram cannot really describe the detail of each method well so I am looking at an activity diagram; however this doesn't typically seem to represent classes and methods, only the logic.
Is there a common or even proper way to show which methods the logic belongs to? I do not need to follow strict UML, the purpose is simply to make it clear what's happening visually.
Activity diagrams and partitions
The activity diagram are supposed to models activities without necessarily relating them to classes/objects. They are however very suitable for modeling complex algorithms, as they allows to show :
the control flow -- flowchart diagrams have proven effective for modeling alorthims; activity diagrams are much more precise in their semantic and can do this as well.
object flows that show what objects are passed through
there are object actions that are specifically meant for dealing with objects
Activity diagrams support partitions, i.e. visual grouping of activities according to a criteria. A popular use is to split actions by using subsystems as grouping criteria. Breaking down by classes seems overkill, but nothing forbids such groupings if it helps, and if you're able to use it consistently.
Interaction overview diagrams
Interaction Overview Diagrams are specialization of Activity Diagrams that represent Interactions.
Interaction overview diagrams are a kind of combination of activity and sequence diagrams. The general idea is to use some activity modeling features for showing the big picture of the flows, between interaction nodes, i.e. mini sequence diagrams embedded in the larger diagram, to show which objects are involved and what messages they exchange.
There is an inspiring example here. But be careful: the linked website is based on a former version of UML and the text is not fully up-to-date. The most accurate source on these diagrams is section 17.10 of the UML 2.5.1 specs.
Additional thoughts
Instead of trying to show everything in one diagram, you may prefer the beauty of simplicity: use an easy to understand, simpler overview diagram, and uncover the complexity in additional diagrams that focus on details. This works with activity diagram complements with more detailed activities or sequence diagrams. But it also works the other way round, showing exchanges between key objects in a sequence diagram, and provide more detailed activity diagrams to describe what happens inside of one of the invoked operation.
Disclaimer: While I provide some hints that you can use to model algorithms in relation with their classes, I have at the same time to warn you that visual programming, i.e. a very very very detailed modeling, may lead to very complex diagrams that are difficult to read, and even more difficult to maintain. They loose the benefit of communicating the big picture. I'm not alone in this criticism, see Grady Booch who knows what he is talking about, since he is one of the co-inventor of UML, Martin Fowler, and many others

Difference between standard and non-standard diagrams in Software engineering

I am writing a documentation for my Software engineering subject. My project is on a Hospital Managements System. Here is the question that is making me confused.
(2. Architectural design) Present the overall software architecture, stating whether it’s Layered,
Repository, Client-Server, or Pipe and Filter architecture( – skim through pages 155 to 164 of our text
reference book to see descriptions of these different architectures). Describe and present it on a standard or non-standard diagram.
So what is the difference between standard and non-standard diagram?
The question is indeed confusing, since it presents architectural models as if they were mutually exclusive (i.e. it can be at the same time layered and client-server) and relies on ambiguous terminology.
When it comes to architectural diagrams, there are standard diagrams, which follow a well known formal graphical notation. Typical examples are:
UML
Older OO notation (e.g. Booch, Rumbaugh or Objectory - it's really old because these have been merged together to make UML).
Non OO notations, such for example the IDEF suite (which was enriched in the meantime with an OO layer), SADT, Gane & Sarson (it's also quite old, less and less used, except in some niche markets).
Among those, the only which qualifies officially and unambiguously as a standard is UML: it's the only one that is recognized by an international standard setting body (ISO/IEC 19505).
But in architecture you have also a fair bunch of non-standard diagrams that convey graphically the structural intent. Typically, a layered arrangement of services, or an hexagonal or a concentric presentations are frequently used. Sometimes it's even more visual with clients shown as PC, and several servers in the network. All these use non-standard notations.

Does a Tool for Automatically Visualizing a Project's Source Code's Control Flow In-Line Exist?

I would like to be able to use a tool that lets you visualize a program's control flow(s) in the context of its source code. To clarify, such a tool should basically show what happens in a program by spitting out a human-readable abstract syntax tree in the form of a multidigraph with nodes containing snippets of source-code translation units. The resulting graph initial node would, I presume, contain the block of code starting with a program's entry point (that'd be main for a C or C++ program.) New nodes would be created when a node needs to reference another block of code, whether that might be in the current file or in another one, and arrows would connect the nodes. Does such a tool exist, or would it have to be created from scratch?
You aren't going to get a tool that does this for arbitrary languages off the shelf. There are too many languages, each with its own syntax and semantics. You somehow need a tool per language. You might find such tools for very commonly used languages, e.g, Understand for Software.
I think that the only way to do this is to build metatools that enable the construction of language-specific tools relatively easily. Such a tool has to have the common machinery needed by all such language processing tools: strong parsers (so writing grammars for languages is relatively straightforward), AST construction machinery, symbol table support, routines to build control and data flow graphs. By providing such machinery, one can build language front ends for modest costs.
There's a class of tools that does this, program transformation. Most of them have parsing engines, but not the rest of the mechanisms I have suggested above.
I believe this enough to have invested 20 years of my life to building
such meta tools. Our DMS Software Reengineering toolkit shows its strength in being able to parse some 50+ languages, including the stunningly hard C++14 (both MS and GNU variants). It shows symbol table support and control flow graph construction for COBOL, Java, C, C++. (We can't do everything at once; pedaling as fast as practical).
[DMS builds these graphs as data structures rather than "showing" them; the examples on that page are drawn with the additional help of DOT].
One of the few other tools that tries to do this is Clang/LLVM; this covers a wide variety of popular languages. Clang doesn't have any specific support for parsing that I know about; you get to code it all yourself. I think you get control flow graphs only after you convert the language to LLVM. I don't think it has any specific support for drawing control flow graphs, either.
An older tool with a good reputation for multi-language support in this space is CoCo/R;
I don't know a lot about it. I know it parses,
and has some support for ASTs; I don't know what it does
about control flow analysis.

Process and tools used in refactoring software

I am looking for re-factoring software for language like C++/Java/C# ... that provide information on how they do re-factoring.
What method they use to detect portion of code that needs re-factoring and how do they keep the program integrity when applying changes. And if possible what tools do they use.
Thanks
If you want to understand how refactoring tools work, you need, as a foundation, to learn essentially how compilers work: parsing, symbol-table construction, various kinds of control and dataflow analysis, program analysis, program transformation. Refactoring engines build on top of this.
Details on how tools handle specific refactorings tend to be found in the software engineering research literature. Check out http://scholar.google.com, and use the search term "refactoring"; you'll get buried under papers that address different kinds of refactorings, and different approaches to doing them.
The question about "finding (single) refactoring tools for list of languages?" is pretty hard to answer. Most refactoring tools are difficult to build (see compiler technology discussion above), so you tend not to see "one" tool that does them all, but rather one tool per language/IDE. Language specific tools are relatively easy to find: google "refactoring tool language".
One insight, however, is that the machinery to do such refactoring tasks have a lot of basic technology foundations in common in the abstract; see my first paragraph above.
It is unfortunate that the way most refactoring tools are built, is to construct all
this machinery for just the one specific refactoring tool, which helps explain why they are hard to build, therefore expensive to build and therefore rare. They are also built using traditional compiler techniques (e.g., traditional parsers [with limitations that cause people to continually complain], and procedural programming (after all, that's the way we've done that since the days of the pyramids, right?).
Tools called program transformation engines try to instantiate this shared commonality, thereby amortizing the cost of building the baseline across many tasks, and to address the problem of building complex code transformations in easier ways, to make it easier to implement such tasks, by providing non-procedural means to express what needs to be done.
You can see an example of program transformations applied to Java; the message from that example is the same transformation engine can be used to "refactor" code in other languages, which is I think what you were originally trying to ask about. (Full disclosure: I'm behind the tool in the example).

Where to start for Tech Specs of an IT project.. more specifically functional specifications

Hi I'm wonderingif someone knows some good resources on writing project specs.
I'm a freelance developer more focused on actual development and less focused
on tech specs.
I'm involved in a proj where have to write technical
specs (& functional req specs) and have absolutely no idea where to
start.. any good site or sample or book you would advise ?
Strongly recommend User Stories Applied by Mike Cohn
Any non-trivial project requires Tech Spec. By non-trivial I mean more than about 1 week of coding or more than 1 programmer.
Although there no much resources online which may help to realize how to make good Tech Specs. So Let me share my vision in this field.
Every spec should contain:
List item
Title
Overview (general words what about the project is)
Operational purpose (what for the project is, the goal)
Functional purpose (the ways and technical methods/resources attained for fulfilling Operational purpose)
Definitions (to avoid polysemy and for clarification purposes)
DATA AND LISTS (the most important and the biggest part of Tech Spec. The section where described data structures, relational database models, choice of programming languages and tools, algorithms, etc)
Wireframes and pages descriptions
Technical requirements (hosting conditions, system requirements, etc)
Сommissioning and acceptance conditions (all criteria which make your job completed)

Resources