OCUP Class Diagram

From Training Material
Jump to navigation Jump to search

Class Basics⌘

Described in the metamodel Kernel package Classes::Kernel.

Most elements of the root model are abstract and are not represented in UML diagrams.

Element⌘

Metaclass Element

  • An element is a constituent of a model.
  • All elements are subclasses of Element
  • Element can own other elements
  • No notation for Element - it is abstract

Relationship ⌘

Relationship class

  • Used to interconnect elements
  • No notation for Relationship as it is abstract

Directed Relationship ⌘

DirectedRelationship class

  • a specialization of a relationship
  • source elements want something - a client
  • target element offers something - a supplier

Comment⌘

  • a textual annotation that can be attached to an element
  • may contain information that is useful to a modeler
  • can be attached to more than one element

Constraint⌘

  • condition or restriction related to an element
  • it must always be true
  • can be in formal (OCL) or human language
  • syntax:
{ [name :] boolean expression }

Classifier⌘

  • an abstract base class
  • describes a set of instances that have features in common
  • Examples of Classifiers:
    • Use Case
    • Class

Feature⌘

  • declares a behavioral or structural characteristic of instances of classifiers
  • structural feature describes a structure of an instance of a classifier (e.g. property)
  • behavioral feature specifies an aspect of the behavior of classifier's instances (e.g. operation)

Property⌘

  • a special structural feature that if it belongs to a class, is an attribute
  • represents a declared state of one or more instances

Operation⌘

  • a behavioral feature of a classifier, which specifies name, type, parameters, and constraints
  • can have preconditions and postconditions
  • can have a type (the type of the return parameter)
  • example:
+ createWindow (location: Coordinates): Window

Class⌘

  • describes a set of objects that share the same specifications of features (attributes and operations)
  • is a special classifier
  • an object is an instance of a class

Generalization⌘

  • relationship between a more general classifier and a more specific classifier
  • each instance of the specific classifier is also an indirect instance of the general classifier
  • the specific classifier inherits the features of the more general classifier

Generalization Example⌘

Association⌘

  • specifies a relationship between instances
  • describes a set of tuples whose values refer to typed instances
  • declares that there can be links between instances of the associated types

Multiplicity⌘

  • specifies how many objects of the opposite class an object can be associated with
  • is a range of the minimum and maximum values
  • syntax: number or min..max
Multiplicity Notation
zero 0 or 0..0
exactly one 1
zero or one 0..1
zero or more 0..* or *
one or more 1..*

Multiplicity example⌘

Multiplicity - order and uniqueness⌘

  • Multiplicity defines a specification of order and uniqueness of the collection elements.
  • This option can specify whether the values should be unique and/or ordered.
    • ordered: the collection of values is sequentially ordered (default: not ordered)
    • unique: each value in the collection of values must be unique (default: is unique)

Property = End or Attribute⌘

  • specifies whether one object can be accessed directly from another

Aggregation⌘

  • shows how something (whole) is composed of parts
  • parts can exist separately - can be shared
  • precise semantics of aggregation varies by application area and modeler :)

Composition⌘

  • a strict form of aggregation
  • the whole is the owner of its parts
  • parts can not be shared
  • the existence of its parts depends on the whole

Aggregation / Composition Example⌘

N-ary association⌘

  • if an association has more than two end points (here: ternary association)
  • Notation: a rhombus is used as a connection point

Dependency ⌘

  • a relationship that signifies that a model element(s) requires other model element(s) for their specification or implementation
  • the complete semantics of the depending elements is dependent on the definition of the supplier element(s)
  • the modification of the supplier may impact the client model elements
  • the semantics of the client is not complete without the supplier
  • the type of dependency can be specified by using a keyword or stereotype

Abstraction⌘

  • a special dependency relationship between model elements that represent the same concept at different levels of abstraction or from different viewpoints

Permit⌘

  • the dependent element is permitted to use private content of this independent element

Substitute⌘

  • instances of the independent element can be substituted by instances of the dependent element at runtime
  • runtime substitutability that is not based on specialization

Usage⌘

  • a relationship in which one element requires another element(s) for its full implementation
  • is limited to the implementation and it doesn’t apply to the specification (dependency do apply)

Interface⌘

  • is a kind of classifier that represents a declaration of a set of coherent public features and obligations
  • an interface specifies a contract; any instance of a classifier that realizes the interface must satisfy that contract
  • it is just declaration - so it is not instantiable


Provided Interface⌘

  • an interface realized by a classifier is its provided interface
  • represent the obligations that instances of that classifier have to satisfy

Required Interface⌘

  • specify services that a classifier needs in order to perform its function

Interface Example⌘

Named Element⌘

  • represents an element that may have a name and a visibility
Visibility Kind Notation
public +
private -
protected #
package ~

Namespace⌘

  • named element that can own other named elements
  • each named element may be owned by at most one namespace
  • provides a container for named elements
  • all the members of a namespace are distinguishable within it

Package⌘

  • used to group elements, and provides a namespace for the grouped elements
  • qualified name:
package name::element name

Package Import, Access⌘

A package import is defined as a directed relationship that identifies a package whose members are to be imported by a namespace.

Two types:

  • «import» for a public package import
    • transitive: if A imports B and B imports C then A indirectly imports C
  • «access» for a private package import
    • intransitive

Package Import Example⌘

  • elements in Types are imported to ShoppingCart, and then further imported to WebShop
  • elements of Auxiliary are only accessed from ShoppingCart, and cannot be referenced from WebShop

Instance ⌘

  • is a concrete instance in the modeled system
  • instance = object