1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems...

38
1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems http://www.csun.edu/~dn58412/IS431/ IS431_SP15.htm

Transcript of 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems...

Page 1: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

1

Systems Analysis & Design

ObjectModeling

IS 431: Lecture 6

CSUN Information Systems

http://www.csun.edu/~dn58412/IS431/IS431_SP15.htm

Page 2: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 2

Object Modeling

Why Object Modeling ?Object Concepts

– Class/Object, Attribute, Behavior, Inheritance, Encapsulation, Message, Polymorphism

UML Diagrams for Object-Oriented Analysis– Use Case Diagram

– Class/Object Diagrams

– Sequence Diagram

– Statechart Diagram

Page 3: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 3

Object Modeling

Object-oriented analysis (OOA) techniques are used to (1) study existing objects to see if they can be reused or adapted for new uses, and (2) define new or modified objects that will be combined with existing objects into a useful business computing application.

Object modeling is a technique for identifying objects within the systems environment and the relationships between those objects.

The Unified Modeling Language (UML) is a set of modeling conventions (notations) to specify or describe a software system in terms of objects.

Page 4: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 4

Object Modeling

Benefits:– Break a complex system into manageable components

– Create reusable components can be plugged into other systems or use them as starting points for other projects

– “Object-think” is more realistic !!!

Page 5: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 5

Object Concepts

An object is something that is or is capable of being seen, touched, or otherwise sensed, and about which users store data and associate behavior.

A class is a set of objects that share common attributes and behavior. A class is also referred to as an object class.

Attributes are the data that represent characteristics of interest about an object.

An instance (or object instance) of an object consists of the values for the attributes that describe a specific person, place, thing, or event.

Page 6: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 6

Classes, Objects, Attributes, & Instances

Customer

custNo lastName firstName phone street city state

changeAddress()

Doe:Customer

custNo:123 lastName:Doe firstName:Joe phone:1234567 street:AnyStreet city:AnyCity state:AnyState

changeAddress()

Green:Customer

custNo:234 lastName:Green firstName:Mary phone:3456789 street:OtherStreet city:OtherCity state:OtherState

changeAddress()

Page 7: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 7

Object Concepts …

Behavior (method, service) refers to those activities that the object can do and which correspond to functions that act on the object’s data (or attributes).

Encapsulation is the packaging of data and method together. It shields the internal working of the object from the changes in the outside system. It keeps the system from being affected when changes are made to objects. It is the key to reusability.– All an object needs to know is the set of methods that

other objects can perform and what message need to be sent to trigger them.

Page 8: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 8

Common Methods

Constructor to create a new instance of a classQuery to access and get info about the state of an

object but does not alter the stateUpdate to alter the state of an object and change the

value of its attribute(s).

Page 9: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 9

Supertypes & Subtypes

A class supertype is an object class whose instances store attributes that are common to one or more class subtypes of the object.

A class subtype is an object class whose instances inherit some common attributes from a class supertype, and then add other attributes that are unique to an instance of the subtype.

Inheritance means that methods and/or attributes defined in an object class (superclass) can be inherited or reused by another object classes (subclasses).

Page 10: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 10

GeneralizationSpecialization

Employee

Name DOB SSN

DateHire CalSeniority()

Executive

Position Location DateAppoint Salary

Update()

Foreperson

Factory Station DateAppoint

Wage Rate Update()

Worker

Factory Station Machine Wage Rate

Insert ()

Page 11: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 11

Object Concepts …

•Message is the information passed when one object invokes one or more of another object's methods (behaviors) to request information or some action

(It is function calling in programming)

Customer

Order

OrderNo OrderDate OrderStatus

add() change() displayStatus()

displayStatus(123)

Page 12: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 12

Object Concepts …

•Polymorphism means “many forms.” In object-oriented techniques, it means that the same message can be interpreted (and a behavior may be completed) differently by different objects/classes.

• Methods of the same name in different classes.

• Methods of the same name (but different parameters) in the same class

• Insert(customer) is different from insert(inventory-item) as different info need to be collected and stored.

Page 13: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 13

Object-Oriented Analysis with UML Diagrams

Modeling the functions of the system (with a use case diagram).

Modeling the objects within the scope of the system and their relationships (with class and object diagrams for each use case, and then for the integrated system).

Modeling the interactions between objects to complete a function/use case (with a sequence diagram for each use case).

Modeling the behavior / logic of the objects (with a statechart diagram for each complex class).

Page 14: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 14

UML Diagrams

Enter New Customer

Create New Order

:customer :order

Create Order

CREATE SIPMENTCREATE ORDER

ORDER

CUSTOMER

SHIPMENT

USE CASE DIAGRAM CLASS DIAGRAM FOR USE CASE

“Create New Order”

SEQUENCE DIAGRAM

FOR USE CASE “Create

New Order”

STATECHART DIAGRAM FOR OBJECT “Order”

Order Clerk

Order Clerk

:shipment

Create Shipment

Page 15: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 15

Use Case Modeling

Use case modeling is the process of modeling a system’s functions in terms of business events, who initiated the events, and how the system responds to the events.

A use case is a complete sequence of related actions (a scenario), both automated and manual, for the purpose of completing a business function: What the system must do.

An actor represents an external entity that needs to interact with the system to exchange information. An actor is a user, a role, which could be an external system as well as a person.

A temporal event is a system event that is triggered by time. (The actor of a temporal event use case is time.)

Page 16: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 16

USE CASE DIAGRAM•Use Case Diagram is a functional description (use cases, actors) of the entire system: functions being supported by the system

•Use Case Diagram is similar to Context Diagram + Level-O DFD in traditional structured technique:

An individual Use Case appears more like a DFD fragment as it identifies an individual function (major process)

In Use Case Diagram, an actor is the one who actually interacts with the system, whether that actor is the original source of information or not (in DFD, an external agent is always the source or destination of info and may not necessarily be the one interacting with the system.)

Use Case Diagram does NOT indicate data flows or flows of information in and out the system (they are identified later in interaction diagrams)

Page 17: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 17

Operations Subsystem

Order Subsystem

Promotion Subsystem

Subscription Subsystem

Submit PastMember

ResubscriptionProgram

Time Marketing

Past Member

Club Member

Potential Member

Generate AnnualSales Analysis

Generate AnnualMembershipAnalysis

Generate QuarterlyMembershipAnalysis

Generate QuarterlySales Analysis

Generate QuarterlyPromotion Analysis

Submit NewPromotion

Submit NewMember

SubscriptionProgram

SubmitResubscription

Submit Change ofAddress

Maintain MemberOrder

Make PurchaseInquiry

Make AccountInquiry

Place NewMember Order

Submit NewSubscription initiates

initiates

initiatesinitiates

initiatesinitiates

initiatesinitiates

initiates

initiates

initiates

initiates

initiates

initiates

initiates

A Use Case Diagram

Page 18: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 18

Extension and Abstract Use Cases

An extension use case extends the functionality of an original use case to add new behaviors or actions to the basic course. An extension use case can only be invoked by the use case it is extending.

An abstract use case contains typical course steps that were common to two or more original use cases. An abstract use case reduces redundancy and promotes reuse.

Page 19: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 19

Extension Use Cases(“extend” relationship)

<<extend>> <<extend>>

Class registration

Registration for special classes

Insufficient prerequisites

“Class registration” is the basic course of actions.

On special occasions, “Registration for special classes” and/or “Insufficient prerequisites” will be invoked.

Special cases add new data/behaviors to the normal case.

Page 20: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 20

Abstract Use Cases(“use” or “include” relationship)

<<include>>

<<include>>

Track sales & inventory

Reorder supplies

Generate reports

“Reorder Supplies” uses “Track sales & inventory” “Generate reports” uses “Track sales & inventory.

In programming, it is a common subroutine.

Page 21: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 21

Building a Use Case Diagram

•Identify use cases (major system functions)

•Identify the system boundary

•Identify associations between use cases (“extends”, “includes”) for special cases or common subroutines

•Identify actors (look at the sources and destinations of major inputs and outputs)

Page 22: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 22

CLASS / OBJECT DIAGRAMS

Class: a set of objects sharing a common structure and a common behavior (Student).

Class Diagram: showing the static structure of OO model: classes, their internal structure, and the relationships.

Object Diagram: showing the graphs of object instances (class members) of a given class diagram: Marie:student (identified object) or :student (unidentified object).

Page 23: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 23

<<actor>>Club Member

Member-Date-Of-Last-OrderMember-Daytime-Phone-NumberMember-Credit-Card-Expire-DateMember-Credit-Card-NumberMember-Credit-Card-TypeMember-Balance-DueMember-Bonus-Balance-AvailableAudio-Category-PreferenceAudio-Media-PreferenceDate-EnrolledEmail-AddressGame-Category-PreferenceGame-Media-PreferenceNumber-Of-Credits-EarnedPrivacy-CodeVideo-Category-PreferenceVideo-Media-Preference

persistent

Member Order

Order-NumberOrder-Creation-DateOrder-Fill-DateShipping-Address-NameShipping-Street-AddressShipping-CityShipping-StateShipping-Zip-CodeShipping-InstructionsOrder-Sub-TotalOrder-Sales-TaxOrder-Shipping-MethodOrder-Shipping-&-Handling-CostOrder-StatusOrder-Prepaid-AmountOrder-Prepayment-Method

persistent

Product

Product-NumberUPC-Quantity-In-StockProduct-TypeSuggested-Retail-PriceDefault-Unit-PriceCurrent-Special-Unit-PriceCurrent-Month-Units-SoldCurrent-Year-Units-SoldTotal-Lifetime-Units-Sold

persistent

Video Title

ProducerDirectorVideo-CategoryVideo-Sub-CategoryClosed-CaptionedLanguageRunning-TimeVideo-Media-TypeVideo-EncodingScreen-AspectMPA-Rating-Code

persistent

Audio Tilte

ArtistAudio-CategoryAudio-Sub-CategoryNumber-Of-Units-In-PackageAudio-Media-CodeContent-Advisory-Code

persistent

Transaction

Transaction-Reference-NumberTransaction-DateTransaction-TypeTransaction-DescriptionTransation-Amount

persistent

Member

Member-NumberMember-NameMember-StatusMember-Street-AddressMember-PO-BoxMember-CityMember-StateMember-Zip-Code

persistent

Agreement

Agreement-NumberAgreement-Expire-DateAgreement-Active-DateFulfillment-PeriodRequired-Number-Of-Credits

persistent

Game Title

ManufacturerGame-CategoryGame-Sub-CategoryGame-PlatformGame-Media-TypeNumber-Of-PlayersParent-Advisory-Code

persistent

Title

Title-Of-WorkTitle-CoverCatalog-DescriptionCopyright-DateEntertainment-CompanyCredit-Value

persistent

Member Ordered Product

Quantity-OrderedQuantity-ShippedQuantity-BackorderedPurchase-Unit-PriceCredits-Earned

persistent

Merchandise

Merchandise-NameMerchandise-DescriptionMerchandise-TypeUnit-of-Measure

persistent

Promotion

Promotion-NumberPromotion-Release-DatePromotion-StatusPromotion-Type

persistent

<<actor>>Potential Member

persistent

<<actor>>Past Member

Expiration-Date

persistent

Return

persistent

1..*

1binds

1

0..*

Conducts

1

0..*

Haspurchased

0..10..*

Generates

0..*

1..*

Features

1

0..*

Sold as

0..*

1

Places

1

1..*

Sells

A Class Diagram

Page 24: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 24

Object/Class Relationships

•An object/class relationship is an association that exists between one or more objects/classes. It is defined by business rules and/or common practices.

•Multiplicity defines how many instances of one object/class can be associated with one instance of another object/class. (It is Cardinality in ERD !!!)

0..*Customer Order

places

Page 25: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 25

UML Multiplicity Notations

Multiplicity Multiplicity

Works for

0..1Has

0..*Makes

UML Notation

Association with Multiplicity Association Meaning

Exactly 1 1

or

leave blank

DepartmentEmployee1Works for

DepartmentEmployee

An employee works for one and only one department.

Zero or one 0..1 SpouseEmployeeAn employee has either one or no

spouse.

Zero or more

0..*

or *

PaymentCustomer

PaymentCustomerMakes *

A customer can make no payment

up to many payments.

One or more 1..* CourseUniversityOffers 1..* A university

offers at least 1 course up to

many courses.

Specific range 7..9 GameTeam

7..9Has

scheduled A team has either 7, 8, or 9 games

scheduled

Page 26: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 26

Aggregation Relationship

Operation Team

Doctor Nurse Admin staff

“is a part of”, “is made of” relationships

Page 27: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 27

Generalization Relationship

Employee

Doctor Nurse Admin staff

-“is a kind of” relationships

- Showing inheritance (type/subtypes)

Page 28: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 28

Building a Class Diagram

•Identify related classes. A class diagram show the classes that are needed for one particular use case, (not for the whole system as in integrated class diagram).

•Identify attributes and operations. List only peculiar, special methods (calculateTax) of the class, not the implicit methods (insert).

•Identify relationships and multiplicity between classes. Make use of generalization and aggregation relationships if possible.

Page 29: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 29

SEQUENCE DIAGRAM

•A Sequence Diagram depicts the interactions among objects of a use case during a certain period of time. It gives an external view of object behaviors.

•A sequence diagram represents a specific set of messages (function calls) and interchanges between objects. Thus, objects are indicated on the diagram instead of classes.

•Each actor and object has a lifeline (from top to bottom) that shows the sequence of message.

•The activation lifeline shows time period during which the object perform an operation. The “X” mark at the end of the activation line indicate the point at which the object ceases to exist in the system.

Page 30: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 30

SEQUENCE DIAGRAM …

•A message symbol in a sequence diagram has 2 parts:

• A directional arrow

•A message descriptor in the form of:

[true/false condition] return-value:= message-name (arguments)

•Sometimes, one can use a return arrow if the return value is not very important

Page 31: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 31

A Sequence Diagram Template for a Use Case

Actor :object 1 :object 2

message 1

message 2

message 3

Page 32: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 32

:product:order :orderedProduct:order- Clerk

:member

display member information

validate item

create item

enter item (product number)

select new order

update address (address)

verify member (member number)

A Sequence Diagram

Page 33: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 33

Building a Sequence Diagram

•Identify objects and the sequence that these objects interact with each other in each use case.

•Identify message (function call) and the sequence

•Draw lifeline and activation boxes (how long we want to keep the class/program active in the system)

Page 34: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 34

STATECHART DIAGRAM

•A Statechart Diagram describes the internal working of an object when it receives a message. Each class in the class diagram for a system has its own unique state diagram.

•An object comes into existence within the system in some manner. During its existence, it is in certain states, and makes transitions from states to states. An object remains in a state until some event causes it to move to another state.

Page 35: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 35

STATECHART DIAGRAM

•A state for an object is a situation during its life when it satisfies some condition, performs some activity, or waits for some event. (A set of values that describe an object at a specific point in time)

•An event is something that takes place at a certain point in time and changes value(s) of an object, (which in turn changes the object’s state).

•Transition is the mechanism that causes an object to leave a state and change to a new state.

Page 36: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 36

A Statechart Diagram Template for an Object

State 1

Internal Trans

State 2

Internal Trans

State 3

Internal Trans

Init state

Final state

Final state

Event 1 Trans 1

Trans 3

Trans 2

Event 2

Page 37: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 37

Order Shipped

Order Released Order Filled

Order Invoiced

PendingIn Process

Order Backordered

Order ClosedMember Order final

state

Member Order finalstate

Member Order initial state

Order pending awaiting payment or additional member information

Order rejected based on Member's past history

Member order archived after 90 days

Invoice sent to member for payment

Response received from memberOrder released

to the warehouse

Order shipped to club member

Order filled by the warehouse

Not all product available

Final payment received

Order submitted

Product received

A Statechart Diagram

Page 38: 1 Systems Analysis & Design Object Modeling IS 431: Lecture 6 CSUN Information Systems dn58412/IS431/IS431_SP15.htm.

IS 431 : Lecture 6 38

Building a Statechart Diagram

•Examine the class diagram and identify which classes must undergo a complex series of state changes and build a statechart diagram for each of them (classes).

•Identify the various states that an object will have over its life time

•Determine what causes each state to occur (change)