Lect Relationships

download Lect Relationships

of 35

Transcript of Lect Relationships

  • 8/13/2019 Lect Relationships

    1/35

    214

    CONCEPTUAL DESIGN:

    UML CLASS DIAGRAMRELATIONSHIPS

  • 8/13/2019 Lect Relationships

    2/35

    215

    1. Identify the information systems purpose

    2. Identify the information systems actors and features

    3. Identify Use Cases and create a Use Case Diagram

    4. Identify Objects and their Classes and create a Class Diagram

    5. Create Interaction/Scenario Diagrams

    6. Create Detail Logic for Operations

    7. Repeat activities 1-6 as required to refine the blueprints

    A Simpl i f ied Object-Oriented

    Systems Analysis & Conceptual Design Methodology

    Activities

  • 8/13/2019 Lect Relationships

    3/35

    216

    Ob jects have three responsib i l it ies:

    What they know about themselves (e.g., A ttr ibutes)

    What they do (e.g., Operations )

    What they know abou t other objects (e.g., Relation sh ips )

    Objects

  • 8/13/2019 Lect Relationships

    4/35

    217

    Defin ing Class

    A CLASS is a template (specif icat ion, blueprint)

    for a col lect ion o f objects that share a commonset of attr ibu tes and operat ions .

    HealthClubMember

    Class

    Objects

    attr ibutesoperat ions

  • 8/13/2019 Lect Relationships

    5/35

    218

    Relat ionships

    A RELATIONSHIP is what a class or an objec t

    knows about another class o r object .

    General izat ion (Class-to-Class ) (Superclass/Subclass)

    Inh eritance

    Ex: Perso n - Faculty Person , StudentPerson, Staff...

    Ex: ModesOfTravel - Airp lane, Train, Auto, Cyc le, Boat...

    [Object ] Associat ions

    Facul tyInformation - Cours eInform at ion

    StudentInform ation - Cou rseInform at ion

    [Object]Agg regat ions & Compos i tion(Whole-Part)

    Assembly - Parts

    Group - Members

    Container - Contents

  • 8/13/2019 Lect Relationships

    6/35

    219

    Relat ionsh ips

    1) show relat ionships 2) enforce integr i ty 3) help produc e results

    Removal of a Univers i ty

    Course should also

    remove Students that are

    in the Course but not

    Student Inform at ion.

    Removal of a Student

    shou ld also remov e the

    Courses that the Student

    is in but no t the Universi tyCourse.

    Removal of a Student in

    a Cours e should not af fect

    e i ther Univers i ty Cou rse or

    Student Inform at ion.

    1

    0,m

    UniversityCourse

    StudentInCourse

    StudentInformation

    1

    0,m

    Exist to:

    In th is examp le:

  • 8/13/2019 Lect Relationships

    7/35220

    UML Class Diagram Notat ion

    Member

    memberNumber

    firstNamelastName

    telephone

    address

    city

    etc...

    checkOutVideocheckInVideo

    buyItem

    etc...

    attributes

    operations

    {{

    Expanded view of aClass into its three

    sections:

    Top: Class Name

    Middle: attributes

    Bottom: operations

    Class

    1 of 2

  • 8/13/2019 Lect Relationships

    8/35221

    Object Association

    n n

    ClassGeneralization

    Relationship

    Object

    Aggregation

    Association

    0..*

    1..*

    Object

    Composition

    Association

    0..*

    1

    UML Class Diagram Notat ion 2 of 2

    Will always be 1

  • 8/13/2019 Lect Relationships

    9/35222

    Class Diagram Relat ionsh ips

    Class

    General ization

    Object

    Associat ion

    Aggregat ion

    Composi t ion

  • 8/13/2019 Lect Relationships

    10/35223

    Generalization (Class-to-Class) (superc lass sub class; super types ubtype)

    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/13/2019 Lect Relationships

    11/35

  • 8/13/2019 Lect Relationships

    12/35225

    Person

    attributes

    operations

    Poor General izat ion Example

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

    Arm

    attributes

    operations

    Leg

    attributes

    operations

    Head

    attributes

    operations

  • 8/13/2019 Lect Relationships

    13/35

  • 8/13/2019 Lect Relationships

    14/35

    227

    General izat ion - Mu lt ip le Inheritance

    Generalization1

    a1a2

    a3

    o3

    o4

    o5

    Specialization

    a6

    a7

    a8

    o6

    o7

    o8

    Generalization2

    a2a4

    a5

    o1

    o2

    o3

    inherited attributes

    a1

    a2 (which one?)a3

    a4

    a5

    inherited operations

    o1

    o2

    o3

    o4

    o5

    (which one?)

  • 8/13/2019 Lect Relationships

    15/35

    228

    UML General izat ion Notat ion

    Supertype

    Subtype 2Subtype 1

    discriminator

    Useful text

    Note

    Note: Supertype = Superclass; Subtype = Subclass

  • 8/13/2019 Lect Relationships

    16/35

    229

    General izat ion - Mu lt ip le Class if icat ion

    Person

    Female

    Male

    Physical-therapist

    Nurse

    Doctor

    role

    Patient

    patient

    Gender

    {complete}

    Discriminator

    #1

    #2

    #3

  • 8/13/2019 Lect Relationships

    17/35

    230Rational Rose Class Diagram Examp le

  • 8/13/2019 Lect Relationships

    18/35

    231

    Assoc ia t ions

    Relationships between instances (objects)

    of classes

    Conceptual:

    associations can have two roles (bi-directional):

    source --> target target --> source

    roles have multiplicity (e.g., cardinality,

    constraints)

    To restrict navigation to one direction only, anarrowhead is used to indicate the navigation

    direction

    No inheritance as in generalizations

    Obj A i i R l i hi P

  • 8/13/2019 Lect Relationships

    19/35

    232

    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 Aattributes

    operations

    Class B

    attributes

    operations

    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/13/2019 Lect Relationships

    20/35

    233

    Assoc ia t ions

    Class A Class Brole A

    role B

    Company PersonEmployer

    Employee

    Example:

  • 8/13/2019 Lect Relationships

    21/35

    234

    Mult ip l ic i t ies

    Class

    Class

    Class

    Class

    1

    0..*

    0..1

    m..n

    exactly one

    many

    (zero or more)

    optional(zero or one)

    numerically

    specified

    Course CourseOffering

    1

    0..*

    Example:

  • 8/13/2019 Lect Relationships

    22/35

    235

    Agg regat ion & Compos i tion

    Agg regation (shared agg regation ):

    is a special ized fo rm 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 abou t agg regat ions:

    who le-parts

    con tainer-con tents

    group-members

    Compos i t ion (compos i te agg regat ion ):

    is a s tron ger 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. Composi t ion vs. Associat ion???

  • 8/13/2019 Lect Relationships

    23/35

    236

    Aggregation Composition

    0..*

    1..*

    Faculty

    CourseTeaching

    1..*

    1

    SalesOrder

    SalesOrderLineItem

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

    (team-teaching

    is possible)

  • 8/13/2019 Lect Relationships

    24/35

    237

    Composi t ion

    Person{abstract}

    Faculty Student

    FacultyStudent

    Person

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

    FacultyRole

    StudentRole

    1

    10..1

    0..1

    Composi t ion is often used in place ofGeneralization (inheritance) to avoid transmuting(adding, copy ing, and delet ing o f ob jects)

  • 8/13/2019 Lect Relationships

    25/35

    238

    Assoc iat ion, Aggregat ion and Composi t ion

    Whole

    Part

    Whole

    Part

    0..*

    0..*

    w

    1w

    2 w

    3w

    4

    p

    6p

    4

    p

    5p

    3p

    1

    p

    2

    Template/Pattern Example

    (assoc iation, aggregat ion &

    composi t ion look the same)

  • 8/13/2019 Lect Relationships

    26/35

  • 8/13/2019 Lect Relationships

    27/35

    240

    Mult ipl ic i ty Example #2

    1..n

    1

    0..*

    2..5

    C1

    C2

    C2

    C2

    C2

    C2

    etc...

    min.max.

    C1

    C3

    C3

    C3

    C3

    C3

    etc...

    C3

    C1

    C1

    C1

    C1

    C11..n * 2..5

    Class1

    Class2 Class3

    C2

    C11

  • 8/13/2019 Lect Relationships

    28/35

    241

    FacultyInformation

    1

    0..*

    1 11

    1..* 0..*

    0..*

    0..*

    Mult ipl ic i ty Example #3

    StudentInformation

    DegreeHeld CommitteeAssign

    CourseTeach ClubMember

    CourseCompleted

    0..*

    man t man m ltiplicit

  • 8/13/2019 Lect Relationships

    29/35

    242

    CourseInformation0..*

    0..*

    many-to-many multiplicity

    attributes

    operations

    StudentInformation

    attributes

    operations

    Becomes either

    0..* 0..*

    SemesterTaken

    GradeEarned

    1 1

    StudentInformation

    attributes

    operations

    CourseInformation

    attributes

    operations

    StudentCourseInformation

    operations

    Attr ibutes that

    represent the

    union of the

    two classes are

    located in th is

    association

    class.

    StudentInformation

    attributes

    operations

    CourseInformation

    attributes

    operations

    0..*

    0..*

    SemesterTaken

    GradeEarned

    StudentCourseInformation

    operations

  • 8/13/2019 Lect Relationships

    30/35

    243

    Ref lexive Association Relat ionships

    Objects with in the same class have a

    relat ionsh ip w ith each other.

    Course

    0..*

    0..*

    has pre-requisite of

    Video Store UML Class Diagram

  • 8/13/2019 Lect Relationships

    31/35

    244

    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..*

    10..*

    11..*

    10..*

    0..*

    1

  • 8/13/2019 Lect Relationships

    32/35

    245

  • 8/13/2019 Lect Relationships

    33/35

    246

  • 8/13/2019 Lect Relationships

    34/35

    247

  • 8/13/2019 Lect Relationships

    35/35

    QUITTING TIME