KEMBAR78
Modelling - Class and Object Diagrams | PDF | Class (Computer Programming) | Inheritance (Object Oriented Programming)
0% found this document useful (0 votes)
9 views3 pages

Modelling - Class and Object Diagrams

Uploaded by

caleb.ng.yy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Modelling - Class and Object Diagrams

Uploaded by

caleb.ng.yy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Modelling

Models are useful for analysing a complex entity related to software development, communicating information among stakeholders, and as a
blueprint for creating software. Models can be considered abstractions.

Modelling structures – Class Diagrams


UML class diagrams describe the structure (but not the behaviour) of an OOP solution (The solution domain, vs. OODM - problem domain).

Purpose Drawing Code Note


Interface The AcademicStaff and the An interface is shown like a class with an
AdminStaff classes implement the additional keyword <<interface>>.
SalariedStaff interface.
When a class implements an interface, it is
shown like class inheritance except a
dashed line is used instead of a solid line.

Class Attributes compartment should be above the


Visibility: Methods compartment.

All attributes and methods should be inside


the same compartment.

Package private Both Attributes and Methods compartments


is the default can be omitted or left empty if no attributes
access modifier. and methods are present.

Underlines denote class-level attributes and


methods.
Abstract class Use italics or {abstract} (preferred) keyword
to denote abstract classes/methods.

Generic class

Inheritance The Car class inherits from the You can use a triangle and a solid line (not
Vehicle class. The Cat and Dog to be confused with an arrow) to indicate
classes inherit from the Pet class. class inheritance.

If ancestors have any Doesn’t matter if the triangle is filled/empty.


unimplemented abstract classes,
you must write them in the If the subclass overrides a method, you can
subclass (if subclass is not write the overridden method inside the
abstract) subclass as normal.
Enumeration

Association Show each association as either an


(Line/ attribute) attribute or a line but not both. A line is
preferred as it is easier to spot.

“ActionFactory adds objects created to


the History object” implies that
ActionFactory has a permanent
reference (association) to History, so that
everything is added to the same object.

Association Association labels describe the meaning


(Labels) of the association. The arrowhead shows
the direction in which the label is to be read.
Association Association Role are used to indicate the
(Roles) role played by the classes in the association.

Optional, useful for differentiating among


multiple associations between the same two
classes.
Association Navigability can be shown in class diagrams
(Navigability) as well as object diagrams.

Association Diagram: an Admin object


(Multiplicity) administers any number of students
but a Student object must always be
under the charge of exactly
one Admin object.
Association A Book is composed of Chapter Solid diamond to denote composition.
(Composition) objects. When the Book is
(Usually for Task destroyed, its Chapter objects are
class) destroyed too.
Association Hollow diamond to indicate an aggregation.
(Aggregation)

Should avoid, optional.


Association Dashed arrow to show dependencies. (We
(Dependency) always show the direction, can be bi)

Association Loan is an association class Denoted as a connection to an association


(Association because it stores information about link using a dashed line.
Class) the borrows association between
the User and the Book.

Association Before: After:


(Convert
Association
Class to
Normal Class)

Idea: You turn


the attributes of
the association
class (which
tracks the
entities) into
roles.

Notes UML notes can augment UML diagrams


with additional information. These notes
can be shown connected to a particular
element in the diagram or can be shown
without a connection.

Modelling structures – Object Diagrams


An object diagram shows an object structure at a given point of time. Don’t show abstract classes, interfaces (we only show the created
objects)

When the class diagram has an inheritance relationship, the object diagram should show either an object of the parent class or the child
class, but not both.

Purpose Drawing Code Note


Object objectName:ClassName says 'an
instance of ClassName identified as
The class name objectName'.
and object name
are underlined. No methods. Multiplicities omitted.

Attributes compartment can be omitted if it is


not relevant to the purpose of the diagram.

Object name can be omitted too e.g.: Car


is meant to say, 'an unnamed instance of a
Car object'.
Association A solid line indicates an association between
two objects.

Association labels/roles can be omitted


unless they add value

You might also like