paper
Chapter 6
Object Modeling
1
Learning Objectives
After this chapter, you will be able to:
Demonstrate how object-oriented analysis can be used to describe an information system
Explain what an object represents in an information system
Explain object attributes
Explain object methods
Explain object messages
Explain classes
IST 603 - Chapter 6
2
2
Learning Objectives
Explain relationships among objects and classes
Draw an object relationship diagram
Demonstrate use of the UML to describe object-oriented systems, including use cases, use case diagrams, class diagrams, sequence diagrams, state transition diagrams, activity diagrams, and business process models
Explain how tools can support object modeling
IST 603 - Chapter 6
3
3
Classes and Objects
Real world has objects - houses, cars, students, buildings, books …
If we refer to a Book, no SPECIFIC book is being referred
But if we refer to System Analysis and Design, a specific book is referred
A Book is therefore a TYPE of objects
There are many Books all over the world
We would think of a Book as a Type that represents any Book anywhere
To generalize, in Object Oriented (OO) paradigm, Book will be called a Class
System Analysis and Design is an instance of the Class known as Book
In OO Paradigm, System Analysis and Design will be called an Object in general
In general, an Object is an instance of a Class
IST 603 - Chapter 6
4
Classes and Objects
University - it is any university anywhere - a Class
Cleveland State University – a specific instance of an University – an object
Course – any course anywhere – a Class
IST 603 – a specific course – an instance of Course – an object
Cat – any cat anywhere – a Class
Pooky – your pet cat – an instance of Cat – an object
To generalize again, a Class is a type, an object is an instance of a type.
IST 603 - Chapter 6
5
Attributes
Each object has certain attributes
For example, a house has square meters, construction date, style, …..
Attributes describe the characteristics of an object
Attributes of an object are defined during the system development process
Objects possess a state
Describes the object’s current status
State can be thought of as the set of values of the object’s attributes
IST 603 - Chapter 6
6
Classes and Attributes
Suppose we have a class called Person with the following attributes
Last Name First Name Gender Date of Birth
Set of values of an object define the current state of that object at that moment
The state, of course, can change as attribute values change
Any number of objects can be instantiated using Person
IST 603 - Chapter 6
7
Taylor Amanda Female 06/17/1995
Smith Robert Male 11/08/1963
Kohli Virat Male 08/21/1991
7
Methods
Tasks or functions that the object performs when it receives a message, or command
IST 603 - Chapter 6
The MORE FRIES method requires the object to perform seven specific steps to complete its task.
8
8
Objects in an Information System
Person, place, event, or transaction that is significant to the information system
An Information System is constructed using many Objects
IST 603 - Chapter 6
The PARENT object includes four attributes and two methods. Mary Smith, Ahmed Ali, and Anthony Greene are instances of the PARENT object.
9
Objects
IST 603 - Chapter 6
The CHILD object includes five attributes and five methods. James Smith, Amelia Ali, and Misty Greene are instances of the CHILD object.
10
10
Objects and Messages
Functionality of an Information System is realized through interaction among objects, sending messages to one another
A control program or another object sends ‘Your Age’ message to Person object
Since Person knows its Date Of Birth, it can calculate the age and return the age to the object requestion it
If Person did not have the information, it can send message to another object to get the necessary information
In a programming context, a message is a method call
IST 603 - Chapter 6
11
Message
Message to the object triggers changes within the object without specifying how the changes must be carried out
Message sender does not have any knowledge of the implementation details of the message receiver
An object can be viewed as black box: Encapsulation
Combination of process and data into a single entity
Encapsulation results in information hiding – only the information required to use the object is published and return information from the object
User of the object does not know or need to know the implementation details - a black box
IST 603 - Chapter 6
12
Inheritance
In OO modeling, higher-level, or more general classes of objects can be created
These objects will have common set of attributes and methods and will be recognized as ‘superclass’
‘Subclasses’ will then inherit from the superclass
These superclass and subclasses are generally organized as a hierarchy
Subclasses can also be thought of as having a-kind-of relationship with the superclass as shown in the example (the next slide)
Subclasses inherit all appropriate attributes and methods from the superclass
In addition, subclasses can define additional attributes and methods appropriate that type
IST 603 - Chapter 6
13
13
Inheritance
IST 603 - Chapter 6
14
Person is the superclass. Has common attributes and methods of the hierarchy
Doctor and Patient inherit from Person
General Practitioner and Specialist inherit from both Person and Doctor
Superclass and Subclass
IST 603 - Chapter 6
At the fitness center, the PERSON superclass includes common attributes and methods. EMPLOYEE is a subclass of the PERSON class. INSTRUCTOR is a subclass of the EMPLOYEE class.
15
15
Polymorphism and Dynamic Binding
Same message can be interpreted differently by different classes of objects
For example, consider we have three different objects: Square, Circle, and Triangle
Each of them have a method called draw()
Suppose we send a message to each these three,
Square draws a square
Circle draws a circle
Triangle draws a triangle
Polymorphism is possible through dynamic or late binding
The specific method used by the object to respond to a message is not determined until the run time
IST 603 - Chapter 6
16
16
Structure and Behavioral Diagrams
A structure diagram, within UML, includes class, object, package, deployment, component, and composite structure diagrams
Structure diagrams are used to provide static relationships in an information systems
Behavioral diagrams are used to show dynamic relationships among objects that represent the information system
We will discuss class and object diagrams – two key structure diagram types
We will also discuss several behavioral diagrams in the next set of slides:
Activity
Use-Case
Sequence
State Transition
Business Process Modeling
IST 603 - Chapter 6
17
17
Relationships Among Classes
Relationships
Primary purpose is to show relationships, or associations that classes have with one another
When multiple classes share a relationship, a line is drawn with the name of the relationship, or roles the classes play in that relationship
A class can also have a relationship with itself
Relationships have multiplicity
Describes how an instance of an object can be associated with other instances
Numbers are placed on the association path to show minimum …maximum number
Several relationships and associations are shown in the next few slides.
IST 603 - Chapter 6
18
18
Associations and Multiplicity
| Exactly one | 1 | A department has one and only one manager | |
| Zero or more | 0..* | An employee has zero to many children | |
| One or more | 1..* | A manager supervises one or more employees | |
| Zero or one | 0..1 | An employee has zero or one spouse | |
| Specified range | 2..4 | An employee can take between two to four vacations each year | |
| Multiple, disjoint ranges | 1..3, 5 | An employee is a member of one to three or five committees |
IST 603 - Chapter 6
19
Department
Manager
1
Employee
Child
0..*
Manager
Employee
1..*
Employee
Spouse
0..1
Employee
Vacation
2..4
Employee
Committee
1..3, 5
19
Association, and Multiplicity
Suppose we have a Customer and a Car
The association shows that a Customer may own zero or one Car
IST 603 - Chapter 6
20
Customer
Car
0..1
owns
20
Composition
This relationship exists when a class comprises of other classes
A composition relationship implies that a child (Leg) cannot exist independent of the parent (Person)
Composition is shown with a ‘filled diamond’ at the parent end of the relationship
IST 603 - Chapter 6
21
21
Aggregation
Aggregation is similar to composition
An aggregation implies that a child (Engine) can exist independent of the parent (Car)
Aggregation is shown with an ‘empty diamond’ at the parent end of the relationship
IST 603 - Chapter 6
22
22
An Association can be Bidirectional
A Patient schedules zero to many appointments; an appointment has one Patient
An appointment has scheduled one or many Doctors; a Doctor has zero to many Appointments
IST 603 - Chapter 6
23
23
Class Diagram
Class diagrams
Show the classes and relationships involved in a use case to be discussed)
Each class appears as a rectangle, with the class name at the top, followed by the class’s attributes and methods
Lines show relationships between classes and have labels identifying the action that relates the two classes
Includes multiplicity
Describes how instances of one class relate to instances of another class
IST 603 - Chapter 6
24
24
Class Diagram
IST 603 - Chapter 6
Class diagram for a sales order use case (attributes and methods omitted for clarity).
25
25
Class Diagram
IST 603 - Chapter 6
26
26
Relationships Among Objects
IST 603 - Chapter 6
Object relationship diagram for a fitness center.
27
An object diagram is instantiation of all or part of a class diagram
27
Activity Diagram
Are used to model behavior in a business process
Can be thought of as a sophisticated data flow diagram
Unlike data flow diagram, activity diagram includes modeling of
Modeling parallel activities
Concurrent activities
Complex decision process
Shows the primary activities in a process and the relationships among activities
Following several slides show notations used in an activity diagram
IST 603 - Chapter 6
28
Activity Diagram Notations
| An Action: non-decomposable piece of behavior | |
| An Activity is used to represent a set of actions | |
| An Object Node: Represents an object that is connected to a set of object flows | |
| A control flow, shows a sequence of execution | |
| An object flow, shows the flow of an object from one activity to another | |
| An initial node, shows the beginning of set of action or activities |
IST 603 - Chapter 6
29
Activity Diagram Notations
| A final-activity node, used to stop all control flows and object flows in an activity | |
| A final-flow node, used to stop a specific control flow or object flow | |
| A decision node, represents test condition | |
| A merge node, is used to bring back different decision paths | |
| A fork node | |
| A join node |
IST 603 - Chapter 6
30
Activity Diagram: Example
IST 603 - Chapter 6
31
Created using LucidChart. Lucidchart.com
Activity Diagram: Register User
IST 603 - Chapter 6
32
Created using LucidChart. Lucidchart.com
Activity Diagram
Activity diagrams
Show actions and events as they occur
Show the order in which the actions take place and identify the outcomes
IST 603 - Chapter 6
An activity diagram shows the actions and events involved in withdrawing cash from an ATM.
33
33
Use Case Modeling
Use case: represents steps in a specific business function or process
An external entity, called an actor, initiates a use case by requesting the system to perform a function or process
IST 603 - Chapter 6
34
Shows what the users can do and how system should respond to the user action
Identified requirements and activity diagrams are used to construct the Use Case model
34
Use Case Description
IST 603 - Chapter 6
The ADD NEW STUDENT use case description documents the process used to add a current student into an existing class at the fitness center.
35
35
Use Case Diagrams
Visual summary of several related use cases within a system or subsystem
The first step is to identify the system boundary which is represented by a rectangle
System boundary: shows what is included in the system (inside the rectangle) and what is not included in the system (outside the rectangle)
IST 603 - Chapter 6
36
36
Use Case Diagram
IST 603 - Chapter 6
A use case diagram to handle work at an auto service department.
37
37
Use Case Diagram: Another Example
IST 603 - Chapter 6
A use case diagram to handle different transactions in a patient appointment system.
38
38
Slightly more elaborate Appointment System
IST 603 - Chapter 6
39
39
Creating Use Case Diagrams and Descriptions
Write flow of events that is useful for later development
Example of one event
The user contacts Registration Office requesting registration
This request suggests there are potentially two classes: User, Registration
The flow of event also shows that the request originates from a user
The flow of event also shows that the receiver of the event is the Registration Office
In general, each use case should comprise of four steps
Primary Actor initiates the execution of the use case by sending a request (possibly data) to the system
The system ensures that the request (and data) is valid
The system processes the request (and data)
The system sends the primary actor the result of processing
IST 603 - Chapter 6
40
40
Sequence Diagram
Sequence Diagrams are Interaction Diagrams and shows interaction among objects
As discussed earlier, objects have attributes and operations (show up as methods in a class)
Objects can send and receive messages
Messages are information sent to an object to tell the object to execute one its behaviors
For example, User Registration Information will receive a message (with data) and to do what it needs to do to insert itself into the system
Important terms
Classes: send or receive messages
Lifelines: represent the time during which the object above it is able to interact with the other objects in the use case
Messages: include additional information about the contents
Focuses: indicate when an object sends or receives message
IST 603 - Chapter 6
41
41
Sequence Diagram
IST 603 - Chapter 6
A sequence diagram with two classes. Notice the X that indicates the end of the CLASS 2 lifeline. Also notice that each message is represented by a line with a label that describes the message, and that each class has a focus that shows the period when messages are sent or received
42
42
Sequence Diagram
IST 603 - Chapter 6
The sequence diagram for the ADD NEW STUDENT use case. The use case description for ADD NEW STUDENT is shown earlier
43
43
State Transition Diagram
State transition diagrams
Show how an object changes from one state to another, depending on events that affect the object
All possible states must be documented in the state transition diagram
States appear as rounded rectangles with the state names inside
IST 603 - Chapter 6
44
44
Business Process Modeling
Business process modeling (BPM)
Represents the people, events, and interaction in a system
Can be used anytime during the systems development process
Compatible with object modeling
Activity Diagrams are often used to show Business Process Model
Uses concept of Swim Lane
Parallel processes can occur in a business – each parallel process is shown in a separate swim lane
IST 603 - Chapter 6
45
45
Summary (1 of 2)
Object modeling is a popular technique that describes a system in terms of objects
Object-oriented terms include attributes, methods, messages, and classes
Objects can send messages, or commands, that require other objects to perform certain methods, or tasks
IST 603 - Chapter 6
46
46
Summary (2 of 2)
Unified Modeling Language (UML) is a widely used method of visualizing and documenting an information system
Use case describes a business situation initiated by an actor, who interacts with the information system
CASE tools provide an overall framework for system documentation
IST 603 - Chapter 6
47
47
PersonYour Age- LastName- FirstName- Gender- DateOfBirth+ GetAge()+ Create()
PersonDoctorGeneral PractitionerSpecialistPatient-memberName-memberName-memberName-memberName-memberName-memberName-memberName-memberName-memberName-memberName
Person-memberName-memberNameHead-memberName-memberNameHand-memberName-memberNameLeg-memberName-memberName
Car-memberName-memberNameEngine-memberName-memberNameWheel-memberName-memberName
Patient-memberName-memberNameAppointment-memberName-memberNameDoctor-memberName-memberNameSchedules 10..*0..*1..*-memberNameHas scheduled
PersonEmployeePatientMedical Historyprovides -->AppointmentBillschedules -->10..10..*1leads to -->0..*1Example (partial) class diagram of a medical system-memberName-memberName-memberName-memberName-memberName-memberName-memberName-memberName-memberName-memberName-memberName-memberName-memberName
Action
Activity
Class Name
Add New Student (Use Case)Student/Manager
Make AppointmentProduce Schedule InformationRecord AvailabilityManagementDoctorPatient
Make AppointmentProduce Schedule InformationRecord AvailabilityManagementDoctorPatientMake old patientAppointmentMake new patient AppointmentMake payment arrangementUpdate patient information<<extends>><<extends>>Manage Schedule<<includes>><<includes>>Appointment System