Unified Modeling Language (UML) What Is UML? Object Management
Total Page:16
File Type:pdf, Size:1020Kb
Unified Modeling Language (UML) Object Management Group (OMG) ● An international, open membership, not-for-profit technology standards consortium that was founded in 1989. https://www.omg.org/ Péter Jeszenszky ● Standards: Faculty of Informatics, University of Debrecen – MetaObject Facility (MOF) https://www.omg.org/mof/ [email protected] – Model Driven Architecture (MDA) https://www.omg.org/mda/ – Systems Modeling Language (SysML) Last modified: April 11, 2021 https://www.omg.org/spec/SysML/ – Unified Modeling Language (UML) https://www.uml.org/ – XML Metadata Interchange (XMI) https://www.omg.org/spec/XMI/ – … 3 What is UML? History ● „The OMG's Unified Modeling Language (UML) ● UML is based on other object-oriented methodologies for helps you specify, visualize, and document software systems development: models of software systems, including their – Booch (Grady Booch) structure and design [...]. (You can use UML for – OMT (Object-Modeling Technique) (James E. Rumbaugh et al.) business modeling and modeling of other non- – OOSE (Object-Oriented Software Engineering) (Ivar Jacobson) software systems too.)” ● „Three Amigos”: Booch, Jacobson, and Rumbaugh – UML were developed under their leadership. – See: Introduction To OMG's Unified Modeling ● Language See also: https://www.omg.org/UML/what-is-uml.htm – The Unified Modeling Language – Versions of UML Versions of UML https://www.uml-diagrams.org/ 2 4 Current Standards XML Metadata Interchange (XMI) ● OMG Unified Modeling Language (OMG UML) Version 2.5.1. ● An XML format for metadata exchange between December 2017. https://www.omg.org/spec/UML/2.5.1/ applications. ● Diagram Definition (DD) Version 1.1. June 2015. https://www.omg.org/spec/DD/1.1/ ● Most often, it is used for the exchange of UML ● XML Metadata Interchange (XMI) Version 2.5.1. June 2015. models, however, it can be used to serialize any https://www.omg.org/spec/XMI/2.5.1/ type of metadata whose metamodel can be ● OMG Meta Object Facility (MOF) Core Specification Version expressed in MOF. 2.5.1. November 2016. https://www.omg.org/spec/MOF/2.5.1/ ● Object Constraint Language Version 2.4. February 2014. https://www.omg.org/spec/OCL/2.4/ 5 7 Object Constraint Language (OCL) Model ● A formal language used to describe expressions on UML models. ● A model is a description of a system, where “system” is meant in ● OCL is not a programming language, instead, it is a modeling the broadest sense and may include not only software and language. hardware but, for example, organizations and processes. – OCL expressions are not directly executable. ● It describes the system from a certain viewpoint for a certain ● OCL expressions are guaranteed to have no side effects. category of stakeholders (e.g., designers, users, or customers of the system) and at a certain level of abstraction. ● OCL is a typed language so that each OCL expression has a type. ● A model is complete in the sense that it covers the whole system, ● OCL can be used for a number of different purposes: although only those aspects relevant to its purpose (i.e., within – As a query language. the given level of abstraction and viewpoint) are represented in – To specify invariants on classes and types in the class model. the model. – To describe pre- and post conditions on operations. – See: OMG Unified Modeling Language (OMG UML) Version 2.5.1. – … December 2017. https://www.omg.org/spec/UML/2.5.1/ 6 8 Metamodell Syntax (1) ● A metamodel is a model of a model. ● Linguistics: – ● “the way in which linguistic elements (such as words) are put In UML, a metamodel is a model used to model together to form constituents (such as phrases or clauses)” itself. – “the part of grammar dealing with this” – It can is used to model itself as well as other ● See: https://www.merriam-webster.com/dictionary/syntax models and metamodels. ● Programming languages: – For example, the MOF model is a metamodel. – “The syntax of a programming language describes the proper form of its programs […].” ● See: Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. Ullman. Compilers: Principles, Techniques, & Tools. 2nd ed. Addison Wesley, 2006. 9 11 Metaclass Syntax (2) ● A metaclass is a class in an object oriented programming language ● Abstract syntax: a description of the structure whose instances are classes. of language elements that is independent of – Python: ● PEP 3115 – Metaclasses in Python 3000 https://www.python.org/dev/peps/pep-3115/ any particular representation. ● Python 3.9.2 documentation – Data model – Metaclasses https://docs.python.org/3/reference/datamodel.html#metaclasses ● Concrete syntax: a mapping of the abstract – Groovy: syntax to a particular (machine) representation. ● The Groovy programming language – Runtime and compile-time metaprogramming http://groovy-lang.org/metaprogramming.html ● groovy.lang.MetaClass http://docs.groovy-lang.org/latest/html/api/groovy/lang/MetaClass.html – UML: classes in a metamodel are called metaclasses (examples of UML metaclesses include Element, Classifier, …). 10 12 Syntax (3) Semantics (1) ● Abstract syntax: ● Concrete syntax: ● Definition (programming languages): – Infix notation: – “The syntax of a programming language describes operator ● (1 + 2) * 3 the proper form of its programs, while the semantics of the language defines what its programs mean; – Prefix notation: that is, what each program does when it executes.” ● arg1 arg2 (* (+ 1 2) 3) ● See: Alfred V. Aho, Monica S. Lam, Ravi Sethi, Jeffrey D. – Postfix notation: Ullman. Compilers: Principles, Techniques, & Tools. 2nd ed. Addison Wesley, 2006. ● ((1 2 +) 3 *) 13 15 Syntax (4) Semantics (2) ● The abstract syntax of UML is specified using a ● The following sentence demonstrates the UML model called the UML metamodel. difference between syntax and semantics: – „Colorless green ideas sleep furiously.” ● See: Noam Chomsky. Syntactic Structures. Mouton & Co., 1957. ● The sentence is grammatically (syntactically) correct, however, it is meaningless. 14 16 Domain-specific languages Meta Object Facility (MOF) (2) ● Domain-specific language (DSL): a computer ● MOF is a domain-specific language for defining language that's targeted to a particular kind of metamodels. problem, rather than a general purpose – The MOF model is used to model itself as well as language that's aimed at any kind of software other models (e.g., UML and CWM). problem. – Can be used to model arbitrary metadata (for – Examples: BibTeX/LaTeX, CSS, DOT (Graphviz), example, software configuration or requirements Gradle DSL, Make, PlantUML, SQL, … metadata). – See: Martin Fowler. DomainSpecificLanguage. https://martinfowler.com/bliki/DomainSpecificLangu age.html 17 19 Meta Object Facility (MOF) (1) Meta Object Facility (MOF) (3) ● The Meta Object Facility (MOF) provides an open ● UML metamodel: and platform-independent metadata management – A UML model that specifies the abstract syntax of framework and associated set of metadata services UML. to enable the development and interoperability of model and metadata driven systems. – This metamodel uses constructs from a constrained subset of UML that is identified in the MOF – Examples of systems that use MOF include modeling specification and used for constructing metamodels. and development tools, data warehouse systems, metadata repositories, etc. ● See: OMG Meta Object Facility (MOF) Core Specification, Version 2.5.1 18 20 The Four-Layer Metamodel Layered Metamodel Architecture Hierarchy (UML 2.4.1) ● ● When dealing with defining languages there are Meta-metamodel (M3): – The primary responsibility of this layer is to define the language for specifying a metamodel. generally three layers that always have to be – A meta-metamodel is typically more compact than a metamodel that it describes. – It is generally desirable that related metamodels and meta-metamodels share common design taken into account: philosophies and constructs. ● Metamodel (M2): – The language specification, or the metamodel. – A metamodel is an instance of a meta-metamodel, meaning that every element of the metamodel is an instance of an element in the meta-metamodel. – The user specification, or the model. – The primary responsibility of the metamodel layer is to define a language for specifying models. ● Model (M1): – Objects of the model. – A model is an instance of a metamodel. – The primary responsibility of the model layer is to define languages that describe semantic domains, i.e., to allow users to model a wide variety of different problem domains, such as software, business processes, and requirements. ● Run-time instances (M0): – Contains the run-time instances of model elements defined in a model. 21 23 Layered Metamodel Architecture Layered Metamodel Architecture ● Metamodeling: ● What is a metamodel in one case can be a model in another case, and this is what happens with UML and MOF. metamodel Class Association – Both UML and MOF are language specifications (metamodels) from which users can define their own «instanceOf» models. «instanceOf» «instanceOf» – From the perspective of MOF, however, UML is viewed as a user (i.e., the members of the OMG that have car model Person Car * developed the language) specification that is based on MOF as a language specification (metamodel). 22 24 The Four-Layer Metamodel Abstract and Concrete Syntax Hierarchy (UML 2.4.1) M3 (MOF) Class ● Example: {subsets owner} + annotatedElement Element + owningElement «instanceOf» * 0..1 «instanceOf» «instanceOf» M2 (UML) classifier Abstract Attribute Class Instance syntax «instanceOf» «instanceOf»