You are on page 1of 22

Review to OO Terminology

• Class: is an extensible template for creating objects, providing


initial values for state (attributes) and implementations of behavior
(methods)
Structure
Behavior

• Object: is a particular instance of a class where the object can be a


combination of attributes and methods
• Relationships between classes such as association and composition
• Package a set of classes

CS443-Software Eng. by Dr. Shouki A. Ebad -


1
Northern Border Univ.
Review to OO Terminology
• Example: Triangle
• Attributes: side1, side2, side3, base and height
• Methods: findArea() and findPerimeter()
• Objects: any type of Triangles like these:

CS443-Software Eng. by Dr. Shouki A. Ebad -


2
Northern Border Univ.
UML
• Unified Modeling Language (UML) is a standardized, general-
purpose modeling language in the field of software engineering
• The UML includes a set of graphic notation techniques to
create visual models of software-intensive systems
• UML 2.2 has 14 types of diagrams divided into two categories:
– 7 diagram types represent structural information
– 7 represent general types of behavior, including four that represent
different aspects of interactions

CS443-Software Eng. by Dr. Shouki A. Ebad -


3
Northern Border Univ.
UML Diagrams

CS443-Software Eng. by Dr. Shouki A. Ebad -


4
Northern Border Univ.
Class Diagrams
• UML provides a class diagram to model classes; including their
attributes, methods, and their relationships with other classes
• The main elements of a class diagram are boxes which
represent classes and interfaces. It is divided into 3 parts as
follows:
Class name

Attributes

Methods

CS443-Software Eng. by Dr. Shouki A. Ebad -


5
Northern Border Univ.
Class Diagrams
• Each attribute can have a name, a type, and a level of visibility
• Visibility is indicated by a preceding:
(+):public (-):private (#):protected
Optional
Thoroughbred Class name

- father: String
- mother: String Attributes
- birthyear: int
+getFather(): String
+getMother(): String Methods
getCurrentAge(currentYear): int

CS443-Software Eng. by Dr. Shouki A. Ebad -


6
Northern Border Univ.
Class Diagrams
• Relationships in Class Diagram:
– Generalization
– Association
– Aggregation
– Composition

CS443-Software Eng. by Dr. Shouki A. Ebad -


7
Northern Border Univ.
Class Diagrams
• Generalization (represented by an arrow like this )
When a class (subclass) that is a specialized form of the other
class (superclass) is connected to it. (“is-a”)
• Association (represented by a solid line or )
A structural relationship that indicates that objects of one class
are connected and can navigate to objects of another class.
(“owns” or “has a”) * owns
Horse Person

Thoroughbred QuarterHorse
CS443-Software Eng. by Dr. Shouki A. Ebad -
8
Northern Border Univ.
Class Diagrams
• Multiplicity in Association:
The UML representation of an association is a line with an
optional arrowhead indicating the role of the object(s) in the
relationship, and an optional notation at each end indicating the
multiplicity of instances of that entity (the number of objects that
participate in the association)
0..1 There are 0 or 1 objects on that end of the association
1..* One object or more
0..* or * 0 or more
1 Exactly one object

CS443-Software Eng. by Dr. Shouki A. Ebad -


9
Northern Border Univ.
Class Diagrams
• Aggregation: (represented by a hollow diamond )
– more specific than association
– part-whole relationship
– Not strong ownership (if the container (whole) is deleted, its contents
(part) are not)
• Composition (represented by a solid diamond )
– An aggregation but with strong ownership (if the container (whole) is
deleted, its contents (parts) are deleted too)
Building College Course

CS443-Software Eng. by Dr. Shouki A. Ebad -


10
Northern Border Univ.
Class Diagrams
Example: show class diagram to model the Banking system
having the classes: Client, Account, Teller, BusinessAccount,
PersonalAccount
(Answer on the board)

CS443-Software Eng. by Dr. Shouki A. Ebad -


11
Northern Border Univ.
Use Case Diagram
• A Use Case (UC) describes how a user interacts with the
system by defining the steps required to accomplish a specific
goal
• A Use Case Diagram is an overview of all the UCs and how
they are related
• A UC Diagram provide a big picture of the functionality of the
system

CS443-Software Eng. by Dr. Shouki A. Ebad -


12
Northern Border Univ.
Use Case Diagram
• In the UC Diagram:
• represents an actor that associated with a user or other
interaction element. Complex systems have more than one actor for
example a vending machine application.
• represents a UC
• connects the actor to the UCs that they carry out
• Note that: (1) None of the details of the UCs are included in the diagram,
(2) The UCs are placed in a rectangle but the actors are not, and (3) This
rectangle shows the system boundaries and that the actors are outside the
system
13
CS443-Software Eng. by Dr. Shouki A. Ebad -
Northern Border Univ.
Use Case Diagram
• Illustrative example
Communication Use case
association

Change a client
contact

Staff Contact

Actor System or subsystem boundary

CS443-Software Eng. by Dr. Shouki A. Ebad -


14
Northern Border Univ.
Use Case Diagram
• Three relationships among UCs
– << include >>: One UC always includes the functionality of
another UC
Why do not we include the second UC in the first to be only
one UC?
– << extends >> : One UC provides additional functionality
that may be required in another use case
– Generalization: like generalization in class diagrams
CS443-Software Eng. by Dr. Shouki A. Ebad -
15
Northern Border Univ.
Use Case Diagram
Example: Hospital Reception subsystem or module supports some
of the many job duties of hospital receptionist. Receptionist
schedules patient's appointments and admission to the hospital,
collects information from patient upon patient's arrival and/or by
phone. For the ("inpatient") he should have a bed allotted in a
ward. Receptionists might also receive patient's payments, record
them in a database and provide receipts, file insurance claims and
medical reports.
(Answer is on the board)
CS443-Software Eng. by Dr. Shouki A. Ebad -
16
Northern Border Univ.
Sequence Diagrams
• In contrast to class diagrams which show the static structure of a
software component, a sequence diagram shows the dynamic
communications between objects during execution of a task.
• It shows the temporal order in which messages are sent between
the objects to accomplish that task

CS443-Software Eng. by Dr. Shouki A. Ebad -


17
Northern Border Univ.
Sequence Diagrams
• Major elements of the sequence diagram:
– Lifeline: to represent an individual participant in the
interaction (as in the figure)
– Message: to specify not only the kind of communication,
but also the sender and the receiver. Message reflects:
• an operation call and start of execution or
• a sending and reception of a signal

CS443-Software Eng. by Dr. Shouki A. Ebad -


18
Northern Border Univ.
Sequence Diagrams
• Message types:
1. Synchronous call: send message and suspend execution while
waiting for response ( )
2. Asynchronous call: send message and proceed immediately
without waiting for return value ( )
3. Reply/ return ( )
4. Create: to create an instance in an interaction («create»)
5. Destroy: to destruct an instance in an interaction («destroy»)
CS443-Software Eng. by Dr. Shouki A. Ebad -
19
Northern Border Univ.
Sequence Diagrams
An example: show how messages are displayed in a sequence diagram
that represents a banking scenario in which a bank customer applies
for a loan by following this process
1. A customer gives an application for the loan to a bank teller
2. The teller sends the application to the bank manager to processed and waits for the
manager to finish
3. The manager starts the credit check program, enters the data, and waits for the credit
agency to send the results
4. The manager receives a response from the credit agency and sends a message to the
teller to state the decision
5. The teller sends a message to the customer to state whether the loan was approved
6. The manager closes the credit agency program and the customer completes the
transaction
(Answer on the board)
CS443-Software Eng. by Dr. Shouki A. Ebad -
20
Northern Border Univ.
State Machine Diagrams
• State diagrams shows how the system reacts
to internal and external events
• They show the system’s responses to stimuli
so are often used for modelling real-time
systems.
• They show system states as rounded
rectangles and events as arcs between these
nodes. When an event occurs, the system
moves from one state to another.
CS443-Software Eng. by Dr. Shouki A. Ebad -
21
Northern Border Univ.
State Machine Diagrams
• Example: The simple microwave oven has a switch to select full or half
power, a numeric keypad to input the cooking time, a start/stop button, and
an alphanumeric display. We have assumed that the sequence of actions in
using the microwave is as follows:
– Select the power level (either half power or full power)
– Input the cooking time using a numeric keypad.
– Press Start and the food is cooked for the given time
For safety reasons, the oven should not operate when the door is open, and, on
completion of cooking, a buzzer is sounded. The oven has a simple display that
is used to display various alerts and warning messages.

(Answer on the board)


CS443-Software Eng. by Dr. Shouki A. Ebad -
22
Northern Border Univ.

You might also like