Top Banner

of 42

4. Class Diagram

Apr 14, 2018

Download

Documents

enworld4u
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
  • 7/29/2019 4. Class Diagram

    1/42

    ObjectOriented

    Analysis,

    ,

    CSE 307 Presentation 8CSE 307 Presentation 8 11

  • 7/29/2019 4. Class Diagram

    2/42

    Overview

    Defineobjectmodelingandexplain itsbenefits.

    Recognize

    and

    understand

    the

    basic

    concepts

    and

    constructs

    ofobjectmodeling.

    .

    Evolveabusinessrequirementsusecasemodelintoasystem

    analysisuse

    case

    model.

    Discoverobjectsandclasses,andtheirrelationships.

    Constructaclassdiagram.

    CSE 307 Presentation 8CSE 307 Presentation 8 22

  • 7/29/2019 4. Class Diagram

    3/42

    Ob ectorientedanal sis OOA ana roach

    usedto studyexistingobjects toseeiftheycanbereusedor

    definenewormodifiedobjects thatwillbecombined

    withexisting

    objects

    into

    auseful

    business

    computing

    Objectmodeling atechniqueforidentifying

    objectswithin

    the

    systems

    environment

    and

    the

    relationshipsbetweenthoseobjects.

    CSE 307 Presentation 8CSE 307 Presentation 8 33

  • 7/29/2019 4. Class Diagram

    4/42

    modelingconventions

    that

    is

    used

    to

    specify

    objects.

    developingsystemsonlyanotationthatisnow

    widel acce tedasastandardforob ect

    modeling.

    CSE 307 Presentation 8CSE 307 Presentation 8 44

  • 7/29/2019 4. Class Diagram

    5/42

    UseCaseModelDiagrams

    Static

    Structure

    Diagrams Classdiagrams

    Objectdiagrams

    InteractionDiagrams Sequencediagrams

    Collaborationdia rams

    StateDiagrams Statechartdiagrams

    Activit dia rams

    ImplementationDiagrams Componentdiagrams

    CSE 307 Presentation 8CSE 307 Presentation 8 55

  • 7/29/2019 4. Class Diagram

    6/42

    ClientClass name compartment

    companyEmail

    companyFaxAttributes compartment

    companyTelephone

    O erations com artment

    Class

    CSE 307 Presentation 8CSE 307 Presentation 8 66

  • 7/29/2019 4. Class Diagram

    7/42

    FoodCo:Client

    companyAddress=Evans Farm, Norfolk

    compartment

    [email protected]

    companyFax=01589-008636Attribute valuescompany ame= oo o

    companyTelephone=01589-008638

    have operations

    CSE 307 Presentation 8CSE 307 Presentation 8 77

  • 7/29/2019 4. Class Diagram

    8/42

    whileclasses

    are

    generally

    permanent.

    .

    Objectinstances

    can

    be

    updated.

    CSE 307 Presentation 8CSE 307 Presentation 8 88

  • 7/29/2019 4. Class Diagram

    9/42

    Partof

    the

    essential

    description

    of

    aclass

    T ecommonstructureo w att ec asscan

    know Eachobjecthasitsownvalue foreach

    attributeinitsclass

    CSE 307 Presentation 8CSE 307 Presentation 8 99

  • 7/29/2019 4. Class Diagram

    10/42

    Yellow Partridge:Client

    A link is a logical connectionbetween two objects

    FoodCo:Client Grace Chia:StaffMember

    Soong Motor Co:Client Carlos Moncada:StaffMember

    CSE 307 Presentation 8CSE 307 Presentation 8 1010Links

  • 7/29/2019 4. Class Diagram

    11/42

    Association role Association

    StaffMember

    Client

    companyAddressstaffContact

    staffNo

    staffStartDate

    companyEmail

    companyFax

    companyName

    liaises with

    companyTelephone

    Association name

    name should be read

    CSE 307 Presentation 8CSE 307 Presentation 8 1111

    Association

  • 7/29/2019 4. Class Diagram

    12/42

    instances.

    fromthesameclass.

    L n canconnect nstanceso tse .

    CSE 307 Presentation 8CSE 307 Presentation 8 1212

  • 7/29/2019 4. Class Diagram

    13/42

    Multiplicityis

    the

    range

    of

    permitted

    Represententerprise (orbusiness) rules

    Anybankcustomermayhaveoneormoreaccounts

    Everyaccountisforone,andonlyone,customer

    CSE 307 Presentation 8CSE 307 Presentation 8 1313

  • 7/29/2019 4. Class Diagram

    14/42

    StaffMember

    ClientMultiplicities

    staffName

    company ress

    companyEmail

    com an Fax

    1 0..*

    staffStartDate companyName

    companyTelephone

    a ses w

    Exactly one staff member liaises with each client

    CSE 307 Presentation 8CSE 307 Presentation 8 1414

    A staff member may liaise with zero, one or more clients

  • 7/29/2019 4. Class Diagram

    15/42

    ClassDiagram:MultiplicityNotationsMultiplicity Notations Example

    Exactly one 1

    blank

    A student studies in exactly one

    department

    ero or one .. e may ave zero or one

    patient

    ..

    *

    more IC

    *..

    teachers

    S ecific Ran e 0..3 A student ma borrow at most 3

    books from the library

    CSE 307 Presentation 8CSE 307 Presentation 8 1515

  • 7/29/2019 4. Class Diagram

    16/42

    Anessential

    part

    of

    the

    description

    of

    aclass

    T ecommon e aviours are ya o jects

    of

    the

    class Servicesthatobjectsofaclasscanprovideto

    otherobjects

    CSE 307 Presentation 8CSE 307 Presentation 8 1616

  • 7/29/2019 4. Class Diagram

    17/42

    ClassDiagram:Operations Operationsdescribe

    whatinstancesofa Campaign

    class

    can

    do: Setorrevealattribute

    actualCostcampaignFinishDatecam ai nStartDate

    values

    Performcalculations

    completionDatedatePaid

    estimatedCost

    Sendmessagestootherobjects

    e

    checkCampaignBudget ( )getCampaignContribution ( )

    Createor

    destroy

    links setCompleted ( )

    CSE 307 Presentation 8CSE 307 Presentation 8 1717

  • 7/29/2019 4. Class Diagram

    18/42

    Thevalues

    of

    the

    attributes

    An

    object

    may

    show

    different

    behavior

    in

    eren s a e

    Statetransitionisinitiatedbyanevent

    Statecan

    be

    changed

    only

    by

    executing

    an

    operation

    CSE 307 Presentation 8CSE 307 Presentation 8 1818

  • 7/29/2019 4. Class Diagram

    19/42

    Ref3:

    Section

    7.3.2

    (page

    165).

    focusoncertainkindofthings.

    rolesobjectscanplay:

    Boundar ob ects

    Entityobjects

    Controlobjects

    CSE 307 Presentation 8CSE 307 Presentation 8 1919

  • 7/29/2019 4. Class Diagram

    20/42

    Modelsinteraction

    between

    the

    system

    and

    Mayincludeinterfacestoothersoftwareor

    devices

    Maintaskistomanagethetransferofinformationacrosss stemboundaries

    CSE 307 Presentation 8CSE 307 Presentation 8 2020

  • 7/29/2019 4. Class Diagram

    21/42

    Notationsforboundaryclass

    User Interface::AddAdvertUI

    User Interface::AddAdvertUI

    startInterface( )

    assi nStaff

    startInterface( )

    assi nStaff

    selectClient( )

    selectCampaign( )

    selectClient( )

    selectCampaign( )

    CSE 307 Presentation 8CSE 307 Presentation 8 2121

    User Interface::AddAdvertUI

  • 7/29/2019 4. Class Diagram

    22/42

    Modelsinformation

    and

    their

    related

    behavior

    , event

    CSE 307 Presentation 8CSE 307 Presentation 8 2222

  • 7/29/2019 4. Class Diagram

    23/42

  • 7/29/2019 4. Class Diagram

    24/42

    Modelthe

    coordination,

    sequencing,

    transactions

    Oneusecaseshouldresultinonecontrolclass

    CSE 307 Presentation 8CSE 307 Presentation 8 2424

  • 7/29/2019 4. Class Diagram

    25/42

    showClientCampaigns( )

    on ro :: ver

    createNewAdvert( )showClientCampaigns( )

    showCampaignAdverts( )

    createNewAdvert

    CSE 307 Presentation 8CSE 307 Presentation 8 2525

    AddAvert

  • 7/29/2019 4. Class Diagram

    26/42

    Use-case Use-casepay fee register

    RegisterPayFee

    PayFeeUI

    ShowResultUI

    CSE 307 Presentation 8CSE 307 Presentation 8 2626

    eg s ra on ee u en n o ne n o ourse n o esu

  • 7/29/2019 4. Class Diagram

    27/42

    Directlybased

    on

    knowledge

    of

    the

    application

    Byproducingaseparateclassdiagramforeach

    use case then assemblin them into a sin le

    model(anAnalysisClassModel)

    CSE 307 Presentation 8CSE 307 Presentation 8 2727

  • 7/29/2019 4. Class Diagram

    28/42

    Identifythe

    likely

    classes

    involved

    (the

    use

    Drawacollaborationdiagramthatfulfilsthe

    needs of the use case

    Translatethiscollaborationintoaclassdia ram

    Repeatfor

    other

    use

    cases

    CSE 307 Presentation 8CSE 307 Presentation 8 2828

  • 7/29/2019 4. Class Diagram

    29/42

    FromUseCasetoClasses:Step1

    Use Case : Assign staff to a campaign

    Actor Action System Response

    1. None 2. Display List of Client Name

    3. Select the client name 4. List the titles of thecampaigns related to that client

    5. Select the relevant campaign 6. Display list of staff not

    ass gne o a campa gn7. Select a staff member to 8. Present a message confirming

    CSE 307 Presentation 8CSE 307 Presentation 8 2929

  • 7/29/2019 4. Class Diagram

    30/42

    Anumber

    of

    tests

    help

    to

    check

    whether

    a

    Isitbeyondthescopeofthesystem?

    Does tre ertot esystemasaw o e

    Doesitduplicateanotherclass?

    Isit

    too

    vague?

    (Moreonnextslide)

    CSE 307 Presentation 8CSE 307 Presentation 8 3030

  • 7/29/2019 4. Class Diagram

    31/42

    Isit

    really

    an

    attribute?

    Isitreallyanassociation?

    ,

    potentialclassinsomeotherway(ordonot

    CSE 307 Presentation 8CSE 307 Presentation 8 3131

  • 7/29/2019 4. Class Diagram

    32/42

    Client

    StaffMember

    CSE 307 Presentation 8CSE 307 Presentation 8 3232

  • 7/29/2019 4. Class Diagram

    33/42

    FromUseCasetoClasses:Step3

    Initialcollaboration

    diagram

    1 2 3

    Campaign

    :Client :Campaign :StaffMember

    Manager

    CSE 307 Presentation 8CSE 307 Presentation 8 3333

  • 7/29/2019 4. Class Diagram

    34/42

    FromUseCasetoClasses:Step3

    Addingboundary

    and

    control

    classes

    1 2

    Campaign

    :AssignStaffUI :AssignStaff

    Manager 5

    43

    CSE 307 Presentation 8CSE 307 Presentation 8 3434

    : en : ampa gn : a em er

  • 7/29/2019 4. Class Diagram

    35/42

    FromUseCasetoClasses:Step3

    Addingmessages

    1 2

    Campaign

    Manager

    :AssignStaffUI :AssignStaff

    7: AssignStaff()

    CSE 307 Presentation 8CSE 307 Presentation 8 3535

    : en : ampa gn : a em er

  • 7/29/2019 4. Class Diagram

    36/42

    FromUseCasetoClasses:Step3

    Finalizing4: selectClient() 5: showClientCampaign()

    10: assignStaff()

    11: asssignStaff()

    2: startInterface()

    Campaign

    Manager

    :AssignStaffUI :AssignStaff

    13: AssignStaff()

    CSE 307 Presentation 8CSE 307 Presentation 8 3636

    : en : ampa gn : a em er

    l

  • 7/29/2019 4. Class Diagram

    37/42

    FromUseCasetoClasses:Step4>AssignStaffUI

    AssignStaff

    assignStaff()

    selectClient()

    selectCam ai n

    getClientCampaign()

    showCampaignStaff()

    Client

    companyName

    Campaign

    site

    StaffMemver

    staffNo

    1 ** 1

    companyAddress

    getClientCampaign()

    campaignStartDate

    getCampaignStaff()

    staffName

    getStaff()

    CSE 307 Presentation 8CSE 307 Presentation 8 3737

    ge en s ass gn a ass gn a

    getStaffDetails()

  • 7/29/2019 4. Class Diagram

    38/42

    tomodel

    interaction

    between

    objects

    Brainstormtheobjects

    A ocatetoteammem ers

    Roleplaytheinteraction

    CSE 307 Presentation 8CSE 307 Presentation 8 3838

  • 7/29/2019 4. Class Diagram

    39/42

    Class Name:

    CollaborationsResponsibilities

    Responsibilities of a class

    are listed in this section.

    o a orat ons w t ot er

    classes are listed here,

    together with a brief

    description of the purpose ofthe collaboration.

    CSE 307 Presentation 8CSE 307 Presentation 8 3939

  • 7/29/2019 4. Class Diagram

    40/42

    Class Name Client

    espons tes o a oratons

    Provide clientinformation.

    campaign details.

    Class Name Campaign

    campaigns.

    Responsibilities Collaborations

    Provide campaign

    information. .Add a new advert.

    .Advert constructs new object.

    Class Name Advert

    Provide advert details.

    Construct adverts.

    CSE 307 Presentation 8CSE 307 Presentation 8 4040

  • 7/29/2019 4. Class Diagram

    41/42

    strategyfor

    distributing

    responsibility

    among

    Forexample:

    ac ro ep ayer r es o e azy

    Persuadesotherplayerstheirclassshouldaccept

    MayusePaperCASEtodocumenttheassoc at onsan n s

    CSE 307 Presentation 8CSE 307 Presentation 8 4141

  • 7/29/2019 4. Class Diagram

    42/42

    ThankYou

    &

    KeepSmiling

    CSE 307 PresentationCSE 307 Presentation 88 4242