UML_reference
UML_reference
https://www.udemy.com/course/uml-class-diagrams-for-programmers
©Riaan Nel
UML Class Diagrams consists of three sections: the class name, attributes, and operations.
Attributes refer to the properties, or fields, or a class. They are expressed as follows:
• Visibility refers to the access modifiers on the attributes, and UML supports the
following access modifiers (relate them back to the programming language in which
you will write your code):
o + (public)
o - (private)
o ~ (package)
o # (protected)
• The name of an attribute is used to identify the attribute.
• The type of the attribute refers to the data type that it will use (String, Integer, etc.).
• The default value of an attribute is optional, and may be left blank.
• The modifier is optional, and serves to provide additional information on the
attribute, such as {readOnly}.
Operations refer to the behaviours, or methods of a class. They are expressed as follows:
• Visiblity and name are self-explanatory - they serve the same purpose as they do on
attributes.
• The parameters refer to the parameters (or method arguments) that will be passed to
the operation when it is invoked. They are represented as follows: <parameter
name>: <parameter type>
This is a supplement for students of the “UML Class Diagrams for Programmers” course and may not be
redistributed.
If you enjoyed this course and you would like to share it with a friend, please use the referral link:
https://www.udemy.com/course/uml-class-diagrams-for-
programmers/?referralCode=617E1ACA20E360B0E995
Course Notes: UML Class Diagrams for Programmers
https://www.udemy.com/course/uml-class-diagrams-for-programmers
©Riaan Nel
• The return type refers to the type of the result returned by the operation, such as
String or Integer (or void, if it does not return anything).
Object-oriented classes have relationships between them - they extend each other
(inheritance), they depend on each other (dependency), they interact with each other
(association), or they form part of each other (aggregation and composition).
Relationships also have multiplicity, which shows how many instances of a class can exist
on each side of a relationship.
Dependency relationships exist when classes depend on each other in such a way that a
change to one class may affect the other, such as when one class accepts an instance of
another class as parameter to a method.
• A dependency relationship can exist when we have a Library class that manages Book
objects. Since the Library class has a method that returns a Book, changes to the
Book class could result in changes to the Library class (based on how Book objects
are created).
Generalization relationships exists when one class extends another class (making it a
specialization of the parent class, like a Car is a specialization of a Vehicle).
This is a supplement for students of the “UML Class Diagrams for Programmers” course and may not be
redistributed.
If you enjoyed this course and you would like to share it with a friend, please use the referral link:
https://www.udemy.com/course/uml-class-diagrams-for-
programmers/?referralCode=617E1ACA20E360B0E995
Course Notes: UML Class Diagrams for Programmers
https://www.udemy.com/course/uml-class-diagrams-for-programmers
©Riaan Nel
• Operations and attributes on the parent class also exist on the child classes, without
being explicitly specified.
• A generalization relationship can exist when we have a system that keeps track of
vehicle rentals, where we have various specialized vehicles.
Association relationships often exist when classes have variables of other types, that they can
invoke operations on.
This is a supplement for students of the “UML Class Diagrams for Programmers” course and may not be
redistributed.
If you enjoyed this course and you would like to share it with a friend, please use the referral link:
https://www.udemy.com/course/uml-class-diagrams-for-
programmers/?referralCode=617E1ACA20E360B0E995
Course Notes: UML Class Diagrams for Programmers
https://www.udemy.com/course/uml-class-diagrams-for-programmers
©Riaan Nel
• Association relationships can also include multiplicity, where we can have one
instance on one side and exactly zero or one instance on the other side, or one
instance on one side zero or more instances on the other side (* refers to any number
of instances), or any other combination.
• An association relationship can exist when we model the relationship between doctors
and patients, where a doctor can have any number of patients and a patient can only
be treated by one doctor at a time.
Aggregation relationships exist when we aggregate (or bring together) objects of one class
in another class.
This is a supplement for students of the “UML Class Diagrams for Programmers” course and may not be
redistributed.
If you enjoyed this course and you would like to share it with a friend, please use the referral link:
https://www.udemy.com/course/uml-class-diagrams-for-
programmers/?referralCode=617E1ACA20E360B0E995
Course Notes: UML Class Diagrams for Programmers
https://www.udemy.com/course/uml-class-diagrams-for-programmers
©Riaan Nel
Composition relationships when objects are composed of (or made up of) other objects.
This is a supplement for students of the “UML Class Diagrams for Programmers” course and may not be
redistributed.
If you enjoyed this course and you would like to share it with a friend, please use the referral link:
https://www.udemy.com/course/uml-class-diagrams-for-
programmers/?referralCode=617E1ACA20E360B0E995
Course Notes: UML Class Diagrams for Programmers
https://www.udemy.com/course/uml-class-diagrams-for-programmers
©Riaan Nel
Notes are used to add additional information to UML Class Diagrams (and other
UML diagrams).
• Notes are represented by a rectangle with the top-right corner folded over.
• Notes can exist on the diagram itself, or they can be linked to specific elements with a
dashed line.
• Template classes are represented by a generic type in a dashed block on the top-right
corner of the class.
• Template classes correspond to generic classes in languages like Java and C#.
This is a supplement for students of the “UML Class Diagrams for Programmers” course and may not be
redistributed.
If you enjoyed this course and you would like to share it with a friend, please use the referral link:
https://www.udemy.com/course/uml-class-diagrams-for-
programmers/?referralCode=617E1ACA20E360B0E995
Course Notes: UML Class Diagrams for Programmers
https://www.udemy.com/course/uml-class-diagrams-for-programmers
©Riaan Nel
• A template class can be used to represent a Container class that can hold objects of a
specific type.
Derived attributes are class attributes that can be calculated based on other values on a class
(or outside of it, such as the current date).
• Derived attributes are indicated by a forward slash (/) preceding the attribute name
(e.g. /age: int ).
• We can use notes to indicate how derived attributes are calculated (although we could
also show this on a sequence- or activity diagram).
• We can use a derived attribute to model a class that calculates a customer's age.
• Keywords on a class (the ones that we use in this course) are indicated in guillemets.
• Constructors share the name of the class and do not specify a return type.
• Constructors can be indicated with the 'constructor' keyword.
This is a supplement for students of the “UML Class Diagrams for Programmers” course and may not be
redistributed.
If you enjoyed this course and you would like to share it with a friend, please use the referral link:
https://www.udemy.com/course/uml-class-diagrams-for-
programmers/?referralCode=617E1ACA20E360B0E995
Course Notes: UML Class Diagrams for Programmers
https://www.udemy.com/course/uml-class-diagrams-for-programmers
©Riaan Nel
• Constructors can also be indicated without the 'constructor' keyword, since one can
easily infer that an operation is a constructor.
Interfaces define contracts for behaviour, but without implementing that behaviour.
Enumerations, or enums, are classes that provide a fixed set of literal values.
If you enjoyed this course and you would like to share it with a friend, please use the referral link:
https://www.udemy.com/course/uml-class-diagrams-for-
programmers/?referralCode=617E1ACA20E360B0E995
Course Notes: UML Class Diagrams for Programmers
https://www.udemy.com/course/uml-class-diagrams-for-programmers
©Riaan Nel
• Enums provide attributes (values), but generally do not provide behaviour, so they can
be drawn without the operations section.
• Enums do not need to show attribute types, since all attributes are of the type of the
enum itself.
• Enums also do not need to show access modifiers, since all attributes are implied to be
accessible if the enum itself is accessible.
This is a supplement for students of the “UML Class Diagrams for Programmers” course and may not be
redistributed.
If you enjoyed this course and you would like to share it with a friend, please use the referral link:
https://www.udemy.com/course/uml-class-diagrams-for-
programmers/?referralCode=617E1ACA20E360B0E995