Top Banner

of 52

Design Class Diagram

Apr 10, 2018

Download

Documents

kgkmahendra418
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
  • 8/8/2019 Design Class Diagram

    1/52

    214

    CONCEPTUAL DESIGN:

    UML CLASS DIAGRAM

    RELATIONSHIPS

  • 8/8/2019 Design Class Diagram

    2/52

  • 8/8/2019 Design Class Diagram

    3/52

    216

    Objects have three responsibilities:

    What they know about themselves (e.g., Attributes)

    What they do (e.g., Operations)

    What they know about other objects (e.g., Relationships)

    Objects

  • 8/8/2019 Design Class Diagram

    4/52

    217

    Defining Class

    A CLASS is a template (specification, blueprint)for a collection of objects that share a common

    set of attributes and operations.

    HealthClubMember

    Class

    Objects

    attributes

    operations

  • 8/8/2019 Design Class Diagram

    5/52

    218

    UML Class Diagram Notation

    Member

    memberNumberfirstName

    lastName

    telephone

    address

    city

    etc...

    checkOutVideocheckInVideo

    buyItem

    etc...

    attributes

    operations

    {{

    Expanded view of a

    Class into its three

    sections:

    Top: Class Name

    Middle: attributesBottom: operations

    Class

    1 of 2

  • 8/8/2019 Design Class Diagram

    6/52

    219

    UML Class Diagram Notation

  • 8/8/2019 Design Class Diagram

    7/52

    220

    Analysis Classes

    A techniqueforfindinganalysisclasses

    whichusesthreedifferentperspectives

    ofthesystem: Theboundarybetweenthesystemandits

    actors

    Theinformationthesystemuses

    Thecontrollogicofthesystem

  • 8/8/2019 Design Class Diagram

    8/52

    221

    Boundary Classes

    coordinatingtheactor'sbehaviorwith

    the "internals" ofthesystem;

    receivinginputfromtheactortothe

    system,e.g.,informationorrequests;

    providingoutputfromthesystemtothe

    actor,e.g.,storedinformationorderivedresults.

  • 8/8/2019 Design Class Diagram

    9/52

    222

    Boundary Classes

    Boundaryclassesareusedtomodel

    theinteractionbetweenasystemanditssurroundings,i.e.,itsactors.

    Userinterfaceclasses

    Concentrateon whatinformationispresented

    totheuser

    Dontconcentrateonuserinterfacedetails

    Example:

    ReportDetailsForm

    ConfirmationDialog

    System / Deviceinterfaceclasses

    Concentrateon whatprotocolsmustbe

    defined.Dontconcentrateonhow the

    protocolsareimplemented

  • 8/8/2019 Design Class Diagram

    10/52

    223

    Entity Classes

    Modelsthekeyconceptsofthesystem

    Usuallymodelsinformationthatis

    persistent

    Containsthelogicthatsolvesthe

    systemproblem

    Canbeusedinmultiplebehaviors

    Example:Violation,Report,Offender.

  • 8/8/2019 Design Class Diagram

    11/52

    224

    Control Classes

    Controlsandcoordinatesthebehaviorofthesystem

    Delegatesthe worktootherclasses

    A controlclassshouldtellotherclassesto

    dosomethingandshouldneverdoanythingexceptfordirecting

    Controlclassesdecoupleboundaryandentityclasses

    Example: EditReportController

    AddViolationController

  • 8/8/2019 Design Class Diagram

    12/52

    225

    Class Diagram Relationships

    Class

    Generalization

    Object

    Association

    Aggregation

    Composition

  • 8/8/2019 Design Class Diagram

    13/52

    226

    Object Association

    n n

    Class

    Generalization

    Relationship

    Object

    Aggregation

    Association

    0..*

    1..*

    Object

    Composition

    Association

    0..*

    1

    2 of 2

    Will always be 1

  • 8/8/2019 Design Class Diagram

    14/52

    227

    Generalization (Class-to-Class) (superclass subclass; supertype subtype)

    A Generalization follows a is a or is a kind of heuristic from a

    specialization class to the generalization class. (e.g., student is a

    person, video is a kind of inventory).

    Common attributes, operations and relationships are located in the

    generalization class and are inherited by the specialization classes

    Unique attributes, operations and relationships are located in the

    specialization classes. Inherited attributes and operations may be overridden or enhanced in

    the specialization class depending on programming language

    support.

    Inherited operations in the specialization classes may be

    polymorphic.

    Only use when objects do NOT transmute (add, copy, delete)

    Multiple inheritance is allowed in the UML but can complicate the

    class models understanding and implementation (e.g., C++ supports

    but Java and Smalltalk do not).

  • 8/8/2019 Design Class Diagram

    15/52

    228

    Role

    attributes

    operations

    Generalization Example

    Faculty

    attributes

    operations

    Student

    attributes

    operations

    Staff

    attributes

    operations

    Visitor

    attributes

    operations

    Note: = no objects

    Others:

    Transactions

    Things

    Places

    Etc...

  • 8/8/2019 Design Class Diagram

    16/52

    229

    Person

    attributes

    operations

    PoorGeneralization Example(violates the is a or is a kind of heuristic)

    Arm

    attributes

    operations

    Leg

    attributes

    operations

    Head

    attributes

    operations

  • 8/8/2019 Design Class Diagram

    17/52

    230

    Generalization Inheritance

    Generalization

    a1

    a2

    a3

    o1

    o2

    o3

    Specialization

    a4

    a5a6

    o4

    o5

    o6

    One-Way

    Inheritance

    from the

    Generalizationto the

    Specialization

    Specialization

    a1

    a2

    a3

    a4

    a5

    a6o1

    o2

    o3

    o4

    o5

    o6(a = attribute; o = operation)

    Common

    Unique

    Generalization

    a1

    a2

    a3o1

    o2

    o3

  • 8/8/2019 Design Class Diagram

    18/52

    231

    Generalization - Multiple Inheritance

    Generalization1

    a1

    a2

    a3

    o3

    o4

    o5

    Specialization

    a6

    a7

    a8

    o6

    o7

    o8

    Generalization2

    a2

    a4

    a5

    o1

    o2

    o3

    inherited attributes

    a1

    a2 (which one?)a3

    a4

    a5

    inherited operations

    o1

    o2

    o3

    o4

    o5

    (which one?)

  • 8/8/2019 Design Class Diagram

    19/52

    232

    UML Generalization Notation

    Supertype

    Subtype 2Subtype 1

    discriminator

    Usefultext

    Note

    Note:Supertype = Superclass;Subtype = Subclass

  • 8/8/2019 Design Class Diagram

    20/52

    233

  • 8/8/2019 Design Class Diagram

    21/52

    234

    Generalization - Multiple Classification

    Person

    Female

    Male

    Physical-

    therapist

    Nurse

    Doctor

    role

    Patient

    patient

    Gender

    {complete}

    Discriminator

    #1

    #2

    #3

  • 8/8/2019 Design Class Diagram

    22/52

    235

    Example

  • 8/8/2019 Design Class Diagram

    23/52

    236Rational Rose Class Diagram Example

  • 8/8/2019 Design Class Diagram

    24/52

    237

    Associations

    Relationshipsbetweeninstances (objects)ofclasses

    Conceptual:

    associationscanhavetworoles (bi-directional):

    source-->target

    target-->source

    roleshavemultiplicity (e.g.,cardinality,

    constraints)

    Torestrictnavigationtoonedirectiononly,an

    arrowheadisusedtoindicatethenavigation

    direction

    Noinheritanceasingeneralizations

  • 8/8/2019 Design Class Diagram

    25/52

    238

    x

    x

    x

    x

    x

    x

    Whole

    attributes

    operations

    PartN

    attributes

    operations

    Part2attributes

    operations

    Part1

    attributes

    operations

    1

    y

    1

    y

    1

    y

    Whole

    attributes

    operations

    PartN

    attributes

    operations

    Part2attributes

    operations

    Part1

    attributes

    operations

    Class A

    attributes

    operations

    Class B

    attributesoperations

    Class A

    attributes

    operations

    Class B

    attributes

    operations

    x

    x

    x

    x

    Object Association Relationship Patterns

    a) Object Associations

    b) Object

    Aggregation

    Associations

    c) Object

    Composition

    Associations(y may not be 1)

  • 8/8/2019 Design Class Diagram

    26/52

    239

    Associations

    Class A Class Brole A

    role B

    Company PersonEmployer

    Employee

    Example:

  • 8/8/2019 Design Class Diagram

    27/52

    240

    Multiplicities

    Class

    Class

    Class

    Class

    1

    0..*

    0..

    1

    m..n

    exactlyone

    many

    (zeroormore)

    optional(zeroorone)

    numerically

    specified

    Course CourseOffering

    1

    0..*

    Example:

  • 8/8/2019 Design Class Diagram

    28/52

    241

    Examples

  • 8/8/2019 Design Class Diagram

    29/52

    242

    Aggregation & Composition

    Aggregation (shared aggregation):

    is a specialized form of ASSOCIATION in whicha whole is related to its part(s).

    is known as a part of or containment

    relationship and follows the has a heuristic

    three ways to think about aggregations:

    whole-parts

    container-contents

    group-members

    Composition (composite aggregation):

    is a stronger version of AGGREGATION the part(s) may belong to only ONE whole

    the part(s) are usually expected to live and

    die with the whole (cascading delete)

    Aggregation vs. Composition vs. Association???

  • 8/8/2019 Design Class Diagram

    30/52

    243

    Aggregation Composition

    0..*

    1..*

    Faculty

    CourseTeaching

    1..*

    1

    SalesOrder

    SalesOrderLineItem

    (another: hand --> finger)(another: assembly --> part)

    (team-teaching

    ispossible)

  • 8/8/2019 Design Class Diagram

    31/52

    244

    Composition

    Person{abstract}

    Faculty Student

    FacultyStudent

    Person

    Note:Attributes may need to be considered to more-fully understand

    FacultyRole

    StudentRole

    1

    1

    0..1

    0..1

    Composition is often used in place of

    Generalization (inheritance) to avoid transmuting

    (adding, copying, and deleting of objects)

  • 8/8/2019 Design Class Diagram

    32/52

    245

    Example

  • 8/8/2019 Design Class Diagram

    33/52

    246

    Association, Aggregation and Composition

    Whole

    Part

    Whole

    Part

    0..*

    0..*

    w

    1w

    2 w

    3w

    4

    p

    6p

    4

    p

    5p

    3p

    1

    p

    2

    Template/Pattern Example

    (association, aggregation &

    composition look the same)

  • 8/8/2019 Design Class Diagram

    34/52

    247

    Whole

    51

    2

    3

    Multiplicity Example #1

    OneWhole is associated with 5 Part1

    One Part1 is associated with 1Whole

    WW

    PP

    PP

    PP

    PP

    PP

    WWPP

    WW

    PP

    PP WWPP

    WW

    WW

    OneWhole is associated with 2 PartN

    One PartN is associated with 3 Whole

    Part1 PartN

  • 8/8/2019 Design Class Diagram

    35/52

    248

    Multiplicity Example #2

    1..n

    1

    0..*

    2..5

    C1C1

    C2C2

    C2C2

    C2C2

    C2C2

    C2C2

    etc...etc...

    min.min.max.max.

    C1C1

    C3C3

    C3C3

    C3C3

    C3C3

    C3C3

    etc...etc...

    C3C3

    C1C1

    C1C1

    C1C1

    C1C1

    C1C11..n * 2..5

    Class1

    Class2 Class3

    C2C2

    C1C11

  • 8/8/2019 Design Class Diagram

    36/52

    249

    FacultyInformation

    1

    0..*

    1 11

    1..* 0..*

    0..*

    0..*

    Multiplicity Example #3

    StudentInformation

    DegreeHeld CommitteeAssign

    CourseTeach ClubMember

    CourseCompleted

    0..*

  • 8/8/2019 Design Class Diagram

    37/52

    250

    Reflexive Association Relationships

    Objects within the same class have a

    relationship with each other.

    Course0..*

    0..*

    has pre-requisite of

  • 8/8/2019 Design Class Diagram

    38/52

    251

    Case studyCourseware Management System

    Problem Statement

    CoursesandTopicsthatmakeupacourse

    Tutors whoteachcourses

    Courseadministrators whomangetheassignmentofthecoursestotutors

    CalendarorCourseScheduleisgeneratedasaresultofthe

    Students whorefertotheCoursescheduleorCalendartodecide whichcoursesforwhichthey wishtosignup

  • 8/8/2019 Design Class Diagram

    39/52

    252

    The potential actors of the system

    Tutors

    Courseadministrators

    Students

  • 8/8/2019 Design Class Diagram

    40/52

    253

    use cases of the system were:

    View courses

    Managetopicsforacourse

    Managecourseinformation

    View coursecalendar

    View tutors Managetutorinformation

    Assigncoursestotutors

  • 8/8/2019 Design Class Diagram

    41/52

    254

    First Identify the "active" entities in the system

    Courseadministrators

    Tutors

    Students

  • 8/8/2019 Design Class Diagram

    42/52

  • 8/8/2019 Design Class Diagram

    43/52

    256

    Identify

    Boundaryclass

    - Course Administrator

  • 8/8/2019 Design Class Diagram

    44/52

    257

    Next

    Identify Attributesandmethodsforthe

    class.

    Refine

  • 8/8/2019 Design Class Diagram

    45/52

    258

    Then

    Identifyrelationshipbetweenthe

    classes.

  • 8/8/2019 Design Class Diagram

    46/52

    259

    Class Diagram

  • 8/8/2019 Design Class Diagram

    47/52

    260

    UML Class Diagram

    Video Store UML Class Diagram

  • 8/8/2019 Design Class Diagram

    48/52

    261

    Inventory

    Video Store UML Class Diagram

    SaleItem RentalItem

    Video Game ConcessionItem VCR

    Transaction Employee StoreLocation

    SaleTransaction RentalTransaction Suplier

    Member PurchaseOrder

    SaleRentalLineItemPurchaseOrderLineItem

    1

    0..*

    0..* 0..1 10..*

    1..*

    1 1

    1..*

    10..*

    1

    0..*

    11..*

    10..*

    0..*

    1

  • 8/8/2019 Design Class Diagram

    49/52

    262

  • 8/8/2019 Design Class Diagram

    50/52

    263

  • 8/8/2019 Design Class Diagram

    51/52

    264

  • 8/8/2019 Design Class Diagram

    52/52

    265

    QUITTING TIME