Class Diagrams Flashcards
class
a construction plan for a set of similar objects
operation <-> method
operation - specification
method - implementation
class structure
name
attributes
operations
attribute visibility
- public: every other class
- private: only the class itself
- # protected: class itself and subclasses
- ~ package: classes in the same package
primitive data type
pre-defined
user-defined
pre-defined types
Boolean, Integer, String, UnlimitedNatural
user-defined
These are custom data types that the user can define using the stereotype «primitive». They represent atomic values and can’t be broken down into more specific types within UML models
composite
Represented with the stereotype «datatype», these types are similar to classes but specifically used for defining value types
- Instances are values not objects
- Identity defined by its properties
- Immutable
enumerations
Enumerations are special data types defined with the stereotype «enumeration» in UML.
They specify a list of possible named values, known as enumeration literals, that an instance of this type can assume.
Pre-defined properties
- {readOnly} … value cannot be changed
- {unique} … no duplicates permitted
- {non-unique} … duplicates permitted
- {ordered} … fixed order of the values
- {unordered} … no fixed order of the values
Direction of the parameter
- in … input parameter
- When the operation is used, a value is expected from this parameter
- out … output parameter
- After the execution of the operation, the parameter has adopted a new value
- inout : combined input/output parameter
Default
instance variable (= instance attribute): attributes defined on the instance level
Class variable (= class attribute, static attribute)
- Defined only once per class,
- i.e., shared by all instances of the class
- e.g., counters for the number of instances of a class, constants, etc.
- Class operation (= static operation)
- Can be used if no instance of the corresponding class was created
- e.g., constructors, counting operations, math functions, etc.
- Can be used if no instance of the corresponding class was created
- Notation: underlining the name of class variable or class operation
coarse grained -> fine grained
Name -> Name + Attributes + Operations -> Name + Attributes with V,Dt + Operations with V, Dt
navigability
an object knows its partner objects and can
therefore access their visible attributes and operations
non-navigability
Indicated by a cross, but this is also often left out
Aggregation
Used to express that a class is part of another class
- Properties of the aggregation association:
- Transitive: if B is part of A and C is part of B, C is also part of A
- Asymmetric: it is not possible for A to be part of B and B to be part of A simultaneously
- Two types:
- (Shared) aggregation
- Composition
generalisation
transitive
Generalization – abstract classes
- Used to highlight common characteristics of their subclasses while ensuring no direct instances of the superclass
- Only its non-abstract subclasses can be instantiated