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