Lecture 10 ISM - © 2010 Houman Younessi Convener: Houman Younessi 1-860-548-7880 [email protected]...

40
Lecture 10 ISM - © 2010 Houman Younessi Convener: Houman Younessi 1-860-548-7880 [email protected] Information Systems Spring 2011
  • date post

    21-Dec-2015
  • Category

    Documents

  • view

    215
  • download

    0

Transcript of Lecture 10 ISM - © 2010 Houman Younessi Convener: Houman Younessi 1-860-548-7880 [email protected]...

Lecture 10

ISM - © 2010 Houman Younessi

Convener:

Houman Younessi

1-860-548-7880

[email protected]

Information SystemsSpring 2011

Lecture 10

ISM - © 2010 Houman Younessi

Structural Modeling: Answers the question WHAT?

We need to concentrate on static relationships between objects (SNAPSHOT). So, we need to depict:

Objects Classes

Links

Associations

Class Diagram

Lecture 10

ISM - © 2010 Houman Younessi

CLASSES

The implementation of a type

A generator for instances

A class is depicted as a solid-outlined rectangle with compartments:

• Must have a name compartment

• May have other compartments (up to 3 more)

Lecture 10

ISM - © 2010 Houman Younessi

The other compartments may contain:

Compartment 2: Attributes

Compartment 3: Operations

Compartment 4: Others (Business rules, exceptions, etc.)

Name Compartment

Attributes Compartment

Operations Compartment

Other Compartment

Widget

color: Color

position:Coord=(0,0)

move(from:Coord,to:Coord=(50,50))

get_color( ):Color

draw( )

draw_all( )

color /= “white”

Lecture 10

ISM - © 2010 Houman Younessi

Class name and the class name compartment:

• The name compartment must be present

• The name compartment contains the name of the class. Class names are centered, begin with a capital letter and are in boldface. Abstract class names are italicized.

Lecture 10

ISM - © 2010 Houman Younessi

Attributes and the attribute compartment:

• May be omitted when drawing high level diagrams

• Are denoted as left justified plain lowercase text strings

• The name may be followed by a colon ( : ) followed by the type of the attribute

• Optionally we can set the initial value of the attribute. To do so, the type name is followed by ( = ) and then the value

Lecture 10

ISM - © 2010 Houman Younessi

• May contain a visibility tag. A visibility tag could be:

• + Public

• # Protected

• - Private

Lecture 10

ISM - © 2010 Houman Younessi

Operations and the operations compartment:

• May be omitted when drawing high level diagrams

• Are denoted as left justified plain lowercase text strings. Abstract operations are italicized

• May have parentheses containing a comma separated list of the parameters of the method that implements the operation.

• Optionally the parameter list may have indicators. These are:

Lecture 10

ISM - © 2010 Houman Younessi

in Parameter is only passed in to the operation

out Parameter is only passed out (returned)

inout Both (Default is “in”)

• May have a return list containing one or a comma separated list of more than one formal parameters following a colon after the parameter list.

• Multiple return parameters, if there, must have a name and a type separated by a colon.

Lecture 10

ISM - © 2010 Houman Younessi

• An operation may have a class scope. Class operations are underlined.

• May contain a visibility tag. A visibility tag could be:

• + Public

• # Protected

• - Private

Lecture 10

ISM - © 2010 Houman Younessi

Attribute

- color:Color=red

Operation:

# credit_rating(in candidate:Customer=current, in agency: Agent=dandb) : rating : Integer, reason : Text

Usually we do not bother with this level of detail unless we aim to generate code automatically

Lecture 10

ISM - © 2010 Houman Younessi

RELATIONSHIPS

There are three basic types of relationship between classes. These are:

• Inheritance

• Aggregation

• Association

Lecture 10

ISM - © 2010 Houman Younessi

INHERITANCE

Parent

Child 2Child 1

Discriminator

…...

Lecture 10

ISM - © 2010 Houman Younessi

Person

FemaleMale

gender

Example:

Lecture 10

ISM - © 2010 Houman Younessi

AGGREGATION

Two types in UML:

• Weak aggregation

• Composition

Brain Person

Department Professor

Composition

Weak aggregation

Lecture 10

ISM - © 2010 Houman Younessi

ASSOCIATIONS

Association shows a named relationship between instances of a class and other instances of itself or between instances of two or more other classes.

Class A Class BRole A:Class

Role B:Class

Name of Association

Multiplicity Multiplicity

Lecture 10

ISM - © 2010 Houman Younessi

Each association has two roles, each role is a direction on the association. These roles can be explicitly named on the association with a label. If not explicitly labeled, then the role name is the same as the target class and may be omitted.

Order Personcustomer

Is placed by

Lecture 10

ISM - © 2010 Houman Younessi

A B

A B

A B

A B

1

1..*

0..1

*

An A is always associated with exactly one B

An A is always associated with one or more B

An A is always associated with zero or one B

An A is always associated with zero or more B

A Bn

An A is always associated with exactly n B

n..m An A is always associated with n to m BWhere n is any integer number greater than 1

Where n,m are integer numbers and m>nA B

Lecture 10

ISM - © 2010 Houman Younessi

An association may have direction. When it does, the direction is shown with an arrow.

A B

In the above diagram, A, is called the source and B is the target.

A bi-directional arrow indicates navigability in both directions.

A B

Lecture 10

ISM - © 2010 Houman Younessi

An association with a “many” side may be ordered. Ordering is shown as a label on the target class.

Screen Window*{ordered}

Visible on

Lecture 10

ISM - © 2010 Houman Younessi

An association may be higher than binary.

A Ternary Association

NameClass A Class B

Class C

Lecture 10

ISM - © 2010 Houman Younessi

reservation

Person Flight

Seat

Example:

Lecture 10

ISM - © 2010 Houman Younessi

Employeesales rep

0..1 *

Corporate Customer Personal Customer

Product

contactName

creditRating

remind()

bill(Real)

creditCard#

Customer

name

address

rating():Integer

1

{if Order.customer.rating = 5

then Order.isPrepaid := True}

*line item

Order

1*

dateReceived: Date

isPrepaid:Boolean

number:String

price:Moneydispatch()

close(Real)

quantity:Integer

price:Money

isFilled: Boolean

creditRating() >=4

Order Line

Lecture 10

ISM - © 2010 Houman Younessi

Event State

A relevant punctuation in time

The arrival of a message

A stimulus received by an object

A relevant interval in time

Response of an object to a message or event

A response to a stimulus

Events take no time States are held in time

Lecture 10

ISM - © 2010 Houman Younessi

coin is inserted(amount)

flight leaves(airline,number)

mouse_button_clicked(button, location)

item_select_mode

cruising

edit_mode

Event State

Events carry information from an object to another (a message), objects receive that information and may change state

Lecture 10

ISM - © 2010 Houman Younessi

Event State

Events can be thought of as a feature call on the

target object.

States can be thought of as an abstraction of the attribute values of the

target object between two relevant events.

Lecture 10

ISM - © 2010 Houman Younessi

SEQUENCE DIAGRAMS

A sequence diagram captures the order of events and the direction of the messages passed.

There are two forms of sequence diagrams:

Simple sequence diagrams (Event Traces)

Full sequence diagrams with concurrency

Lecture 10

ISM - © 2010 Houman Younessi

caller:Person callee:PersonModem1:Modem modem2:Modema_line:Connection

wake connect

sound_dial_toneacknowledge

accept_dial_ sequence

ringing_tone

disconnect

dial_tone

dial

sound_ring_tone

connect

stop_ring_tone

disconnect_signalbreak_connect break_connect

stop_ring

connect

picked_ up

ring_phone

routed

receive_call_ signal

dial_tone

phone_ringing

connected connected

sound_dial_tone sound_dial_tone

Lecture 10

ISM - © 2010 Houman Younessi

modem1:Modem a_Line:Connection

connect()

sound_dial_tone()

*[n]dial(n:Digit)

modem2:Modem

sound_ring_tone() ring_tone()

picked_up()

connect() connect()[while caller not hang_up()]

disconnect signal()

break_connection()

[while caller not hang_up()]

*[n]dial(n:Digit)5

Asynch. Event

Synch. Event

Activation

Continuation Condition

Iteration Condition

Object life termination

routed()

receive_call_signal()

stop_ ringing_tone() stop_ ringing()

break_connection()

sound_dial_tone()sound_dial_tone()

Lecture 10

ISM - © 2010 Houman Younessi

modem1:Modem a_Line:Connection

connect()

sound_dial_tone()

*[n]dial(n:Digit)

modem2:Modem

sound_ring_tone() ring_tone()

picked_up()

connect() connect()[while caller not hang_up()]

disconnect signal()

break_connection()

routed()

receive_call_signal()

stop_ ringing_tone() stop_ ringing()

break_connection()

sound_dial_tone()sound_dial_tone()

caller:Person callee:Personwake

acknowledge

ringing_tone

connected

disconnect

dial_tone

phone_ringing

connected

dial_tone

dial

Lecture 10

ISM - © 2010 Houman Younessi

modem1:Modem a_Line:Connection

connect()

sound_dial_tone()

*[n]dial(n:Digit)

modem2:Modem

sound_ring_tone() ring_tone()

picked_up()

connect() connect()[while caller not hang_up()]

disconnect signal()

break_connection()

routed()

receive_call_signal()

stop_ ringing_tone() stop_ ringing()

break_connection()

sound_dial_tone()sound_dial_tone()

wake

acknowledge

ringing_tone

connected

disconnect

dial_tone

Phone_ringing

connected

dial_tone

caller

caller

caller

caller

caller

callercallee

callee

callee

dial

Lecture 10

ISM - © 2010 Houman Younessi

COLLABORATION DIAGRAMS

Collaboration diagrams also show the message exchange (collaboration) between several objects. They do so by depicting the message exchange between object icons through numbering the messages traveling between these objects.

Lecture 10

ISM - © 2010 Houman Younessi

Modem:modem_2

Connection:aLine

1- connect() 3- *[n] dial(n:Digit) 10- disconnect_signal()

2- sound_dial_tone () 6a- ringing_tone() 8a- stops_ring_tone() 9a-connect( ) 11a- break_connection()12a- sound_dial_tone

4- receive_call_signal() 6b- sound_ring_tone() 8b- stop_ringing() 9b- connect() 11b-break_connection()

12b- sound_dial_tone()

5- routed() 7-picked_up()

Modem:modem_1

EXAMPLE COLLABORATION DIAGRAM

Lecture 10

ISM - © 2010 Houman Younessi

STATE DIAGRAMS

A state diagram relates events and states.

State diagrams may be drawn from the perspective of the whole system as a single object, or from the perspective of any single object at any level of granularity.

State diagrams may show concurrency or may be nested

Usually it is best to draw the state diagram of only one object in the system at a time

Lecture 10

ISM - © 2010 Houman Younessi

idle dial tone

do/sound_dial_tone()

connecting

do/receive_call_signal()

ringing

do/sound_ring_tone()do/ring_phone()

connected disconnect_signal(

)picked_up()

dial()

routed()

connect()

disconnected

reset()

State Diagram of a modem communication line, normal case, successful connection.

connected

do/stop_ring_tone() do/stop_ring()do/connect()

do/break_connection() do/sound_dial_tone()

Lecture 10

ISM - © 2010 Houman Younessi

idle dial tone

do/sound_dial_tone()

connecting

do/receive_call_signal()

ringing

do/sound_ring_tone()do/ring_phone()

connected

disconnect_signal()

picked_up()

dial()

routed()

connect()disconnected

reset()

connected

do/stop_ring_tone() do/stop_ring()do/connect()

do/break_connection() do/sound_dial_tone()

time-out

do/ beep()

time_out()

busy tone

do/ slow_tone()

busy_num()

fast busy tone

do/fast_tone()

busy_trunk()

message

do/play()

message-done()invalid_num()

reset()

State Diagram of a modem communication line, with normal, and a number of non-normal cases.

Lecture 10

ISM - © 2010 Houman Younessi

ringing

do/sound_ring_tone ( )

idle

connect

do/connect ( )acknowledge do/acknowledge ( )

dial do/dial( )

data ex.

disconnectingdo/disconnect_signal()

wake()

sound_dial_ tone() dial()

stop ringing() connect( )

disconnect()

break_connection()

sound_ringing_tone()

sound_dial_tone()

Lecture 10

ISM - © 2010 Houman Younessi

Transformations

This is the third modeling view. It answers the question “how”.

Depending on level of granularity there are many techniques. Including:

High Level:

Activity Diagrams

Low Level:

Pseudocode

Flowcharts

etc.

Not part of UML

Lecture 10

ISM - © 2010 Houman Younessi

Activity diagrams depict the processing aspects of the system. They are similar to flowcharts except:

ACTIVITY DIAGRAMS

Activity charts allow synchronization

They are similar to dataflow diagrams except:

Communication between activities is via messages carrying data not the data itself

Activity charts allow synchronization

Lecture 10

ISM - © 2010 Houman Younessi

Order ProcessingFinance

Stock ManagerReceive

Order

Receive

Supply

Select Outstanding order item

Assign Goods to

OrderAssign Item to Order

Reorder

Item Add Remainder

to Stock

Check Line Item

Cancel Order

Check order

Authorize payment

[failed][succeeded]

Dispatch Order [Stock assigned to all line items and

payment authorized]

*[for each line item on order]

* [for each chosen order item]

[in stock]

[all outstanding order items filled]

[notify supply]

[out of stock]