UML Structural Models Flashcards
When is modelling in software development relevant?
Throughout the entire development process.
Analysis
System design
Detailed design
Implementation
Quality Assurance
Maintenance
What are the three structural diagrams we have discussed in class?
Class diagrams, object diagrams, deployment diagrams
Class diagram:
How to draw class
Rectangle with name.
Three sections:
name, attributes, methods
Class diagram:
Attribute
In second section.
<Visibility> <name> : <type>
</type></name></Visibility>
Class diagram:
Method
In third section.
<Visibility> <name>() : <type>
<Visibility> <name>(<parameters>) : <type>
Parameter: <name> : <type>
</type></name></type></parameters></name></Visibility></type></name></Visibility>
Class diagram:
Visibility modifiers
Private -
Public +
Protected #
Class diagram:
Class members
Underlined
Same value/declaration for all objects of class
Static in Java
Class diagram:
Comments
Add little note with flap in right corner and dotted line to where the comment is for.
Class diagram:
Associations
Specifies that there is a reference between the involved entities.
Reference to another class’ objects
Class diagram:
Aggregation
Empty diamond arrow.
A special case of association.
The objects of the referenced class are “owned” (unlike plain association)
The aggregation implies a relationship where the child can exist independently of the parent.
Library is made up of one or more books. Diamond shape near parent class.
Class diagram:
Composition
Filled out diamond arrow.
A special case of association.
The objects of the referenced class are “owned” (unlike plain association)
A composition means that the referenced object is ‘part of’ the referencing object – manages the lifecycle of the referenced object.
That is, the contained class will be obliterated when the container class is destroyed. For example, a shoulder bag’s side pocket will also cease to exist once the shoulder bag is destroyed.
Again diamond at parent class.
Class diagram:
Abstract classes and methods
Writing in italics.
The UML Generalisation denotes inheritance similar to Java albeit with a different terminology.
Sub-class == specialisation
Super-class == generalisation
Class diagram:
Interface
Are marked by so called stereotypes.
In first section:
«interface»
<name>
Second:
nothing
Third:
<visibility> <name>() : <type>
</type></name></visibility></name>
Class diagram:
enumeration
Are marked by so called stereotypes.
Two sections.
«enumeration»
<name>
all the different categories
</name>
Protected visibility in UML vs Java
UML: visible only for class and subclasses
Java: Visible for class, subclass, and same package.
Multiple inherence UML vs java
java doesn’t support multiple inherence but UML does
Class diagram:
Inheritance (or generalisation)
A generalisation is a taxonomic relationship between a more general classifier and a more specific classifier.
The relationship is displayed as a solid line with a hollow arrowhead that points from the child element to the parent element.
I.e. class Rectangle extends BaseShape
relationship between abstract class and subclasses of it
Class diagram:
Association
Simple association is just regular arrow ->
A structural link between two peer classes.
Class diagram:
Dependency
An object of one class might use an object of another class in the code of a method. If the object is not stored in any field, then this is modelled as a dependency relationship.
Exists between two classes if changes to the definition of one may cause changes to the other (but not the other way around).
The relationship is displayed as a dashed line with an open arrow.
I.e. person takes object book and return true if read.
Class diagram:
Realisation
Realization is a relationship between the blueprint class and the object containing its respective implementation level details. This object is said to realize the blueprint class. In other words, you can understand this as the relationship between the interface and the implementing class.
I.e. between an interface and class that implements interface. Arrow pointing on interface.
Dashed line with filled out arrow.
Object diagrams primary use
Is to make an example of instances of classes, e.g. to explain certain value constellations.
Show example of objects with their specific values.
Object diagram, how to draw object
Two sections:
name: Class (underlined)
attribute = value
example:
norbert : TurtleBot (underlined)
name = “Norbert”
Object diagram:
Object
Instance of class
Header is underlined
Name is optional i.e. :TurtleBot
Object digram
Attributes
Have values (if relevant)