2.3 UML Class Models Flashcards
What is UML used for?
To represent our software analysis
What is a UML Class Digram?
aka static structure diagram
contains representations of:
- classes
- interfaces
- objects
- relationships
What is a Class?
A description of a similar set of instances.
What type of word makes a good class candidate?
Nouns
What are candidates for a Class?
- domain objects
- roles
- events
-interactions
How is a class represented visually in UML?
Denoted by a rectangle with three horizontally partitioned units.
- Name (required)
- Attributes
- Operations
What does it mean when a class name is in italics?
It’s an abstract class.
Abstract classes describe the properties of subclasses but NEVER have their own instances.
Why might you want to use an abstract class?
If you have related subclasses that have common features you can factor those features up into the abstract class.
What are the symbols for visibility?
+ public
- private
# protected
~ package
What attributes can you specify?
- name
- type
- (optional) multiplicity and ordering
- (optional) initial value
- (optional) derivation
- properties e.g., {frozen}
What operation parameters can you specify?
- name
- type
- default value
- kind (in, out, inout)
What operation properties can you specify?
- {query}
- {concurrency}
- {abstract}
- class scope (shown by an underline)
What does an Interface require in UML?
Describe what the interface provides and requires.
parameterized classes
Parameterized classes correspond to Java generics
nested classes
- suitable for inner classes
composite objects
- class diagrams within class rectangles
verbs describe relationships
association - people drive vehicles
generalization - a car is a kind of vehicle
dependencies - dependency between cars and pollution laws: if pollution laws change then cars might have to be adapted
Aggregation vs Composition?
Say you have two classes: House and Room.
A House has a Room, but if you destroy the House, you also destroy the Room. Therefore, the association is NOT an aggregation but a Composition (open diamond).
In Composition there’s a responsibility for managing the lifetime of the constituent objects.
A particular constituent can only belong to one Composition.
Compositions also have the transitive property e.g., House can have Rooms and Rooms can have Closets. There is no such property for aggregations.
Aggregation = Open Diamond
Composition = Closed Diamond
What is a qualifier?
A class attribute that provides access to instances of a particular class.
e.g., like the key in a database table.
What is a link?
Just like classes can have instances, associations can have links.
generalization
generalization is not inheritance. inheritance is an implementation whereas generalization is a modeling technique.
What is overlapping vs disjoint?
Overlapping means a child class can inherit from more than one parent.
Disjoint means a child class can only inherit from one parent.
What is complete vs incomplete?
Does the set of child classes cover all of the instances? if so, it’s complete, else incomplete.