uml ch2 lect

Upload: muhammadrizvannislamkhan

Post on 23-Feb-2018

216 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/24/2019 UML Ch2 Lect

    1/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 16

    UML First Pass: Use Case Diagrams

    WatchUser WatchRepairPerson

    ReadTime

    SetTime

    ChangeBattery

    Actor

    Use case

    PackageSimpleWatch

    Use case diagrams represent the functionality of the system

    from users point of view

  • 7/24/2019 UML Ch2 Lect

    2/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 17

    UML First Pass: Class Diagrams

    Battery

    load()

    1

    2

    Time

    now()

    PushButton

    state

    push()

    release()

    1

    1

    1

    1

    1

    2

    blin!d"

    blinSeconds(

    )

    blin#inutes(

    )

    blin$ours()

    stopBlining(

    )

    re%eresh()

    &C''isplay

    SimpleWatch

    Class

    AssociationMultiplicity

    Attributes

    Operations

    Class diagrams represent the structure of the system

  • 7/24/2019 UML Ch2 Lect

    3/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 18

    UML First Pass: Sequence Diagram

    Object

    MessageActivation

    Sequence diagrams represent the behavior as interactions

    blin$ours()

    blin#inutes()

    increment#inutes()

    re%resh()

    commitewTime()

    stopBlining()

    pressButton1()

    pressButton2()

    pressButtons1nd2()

    pressButton1()

    *WatchUser *Time*&C''isplay

    *SimpleWatch

  • 7/24/2019 UML Ch2 Lect

    4/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 19

    button1+2Pressed

    button1+2Pressed

    button1Pressed

    button2Pressed

    button2Pressed

    button2Pressed

    button1Pressed

    button1+2Pressed !ncrement#inutes

    !ncrement$ours

    Blin$ours

    BlinSeconds

    Blin#inutes

    !ncrementSeconds

    StopBlining

    UML First Pass: Statechart Diagrams

    StateInitial state

    Final state

    Transition

    Event

  • 7/24/2019 UML Ch2 Lect

    5/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 22

    UML Second Pass: Use Case Diagrams

    Used during requirements elicitation torepresent external behavior

    Actorsrepresent roles, that is, a type

    of user of the system Use casesrepresent a sequence of

    interaction for a type of functionality

    The use case model is the set of alluse cases. It is a complete descriptionof the functionality of the system andits environment

    Passenger

    PurchaseTicet

  • 7/24/2019 UML Ch2 Lect

    6/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 24

    Use Case

    A use case represents a class offunctionality provided by the system asan event flow.

    A use case consists of: Unique name

    Participating actors

    Entry conditions

    Flow of events Exit conditions

    Special requirements

    PurchaseTicet

  • 7/24/2019 UML Ch2 Lect

    7/15Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 25

    Use Case Example

    Name:Purchase ticket

    Participating actor:Passenger

    Entry condition:

    Passengerstanding in frontof ticket distributor.

    Passengerhas sufficientmoney to purchase ticket.

    Exit condition:

    Passengerhas ticket.

    Event flow:1.Passengerselects the number

    of zones to be traveled.

    2. Distributor displays the amountdue.

    3.Passengerinserts money, ofat least the amount due.

    4. Distributor returns change.

    5. Distributor issues ticket.

    Anythingmissing?

    Exceptional cases!

  • 7/24/2019 UML Ch2 Lect

    8/15Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 26

    The,,e"tend-- Relationship

    relationships representexceptional or seldom invoked cases.

    The exceptional event flows arefactored out of the main event flowfor clarity.

    Use cases representing exceptionalflows can extend more than one usecase.

    The direction of a relationship is to the extended usecase

    Passenger

    PurchaseTicet

    Time/ut

    ,,e"tend--

    oChange

    ,,e"tend--/ut/%/rder

    ,,e"tend--

    Cancel

    ,,e"tend--

  • 7/24/2019 UML Ch2 Lect

    9/15Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 27

    Passenger

    PurchaseSingleTicet

    Purchase#ultiCard

    oChange

    ,,e"tend--

    Cancel

    ,,e"tend--

    ,,include--

    Collect#oney

    ,,include--

    The Relationship

    An relationship representsbehavior that is factored outof the use case.

    An representsbehavior that is factored out

    for reuse, not because it is anexception.

    The direction of arelationship isto the using use case (unlike

    relationships).

  • 7/24/2019 UML Ch2 Lect

    10/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 29

    Classes

    Aclassrepresent a concept.

    A class encapsulates state (attributes)and behavior (operations). Each attribute has atype.

    Each operation has asignature.

    The class name is the only mandatory information.

    0one2price

    getones()

    getPrice()

    Tari%%Schedule

    Table0one2pricenumerationgetones()

    PricegetPrice(one)

    Tari%%Schedule

    Name

    Attributes

    Operations

    Signature

    Tari%%Schedule

  • 7/24/2019 UML Ch2 Lect

    11/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 34

    Aggregation

    Anaggregation

    is a special case of association denoting aconsists of hierarchy.

    Theaggregateis the parent class, thecomponentsare thechildren class.

    1

    "haust System

    #u%%ler Tailpipe

    3442

  • 7/24/2019 UML Ch2 Lect

    12/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 35

    Composition

    A solid diamond denotecomposition, a strong form ofaggregation where components cannot exist without theaggregate.

    5

    Ticet#achine

    oneButton

  • 7/24/2019 UML Ch2 Lect

    13/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 36

    Generalization

    Generalization relationships denote inheritance between classes.

    The children classes inherit the attributes and operations of theparent class.

    Generalization simplifies the model by eliminating redundancy.

    Button

    oneButtonCancelButton

  • 7/24/2019 UML Ch2 Lect

    14/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 38

    UML Sequence Diagrams

    Used during requirements analysis To refine use case descriptions

    to find additional objects(participating objects)

    Used during system design

    to refine subsystem interfaces

    Classesare represented bycolumns

    Messagesare represented byarrows

    Activationsare represented bynarrow rectangles

    Lifelinesare represented bydashed lines

    selectone()

    picupChange()

    picUpTicet()

    insertCoins()

    PassengerTicet#achine

  • 7/24/2019 UML Ch2 Lect

    15/15

    Bernd Bruegge & Allen Dutoit Object-Oriented Software Engineering: Conquering Complex and Changing Systems 39

    UML Sequence Diagrams: Nested Messages

    The source of an arrow indicates the activation which sent themessage

    An activation is as long as all nested activations

    selectone()

    Passenger oneButton Tari%Schedule 'isplay

    looupPrice(selection)

    displayPrice(price)

    price

    Dataflow

    to be continued...