Lec23 & 24_Object Oriented Analysis and Design

download Lec23 & 24_Object Oriented Analysis and Design

of 61

Transcript of Lec23 & 24_Object Oriented Analysis and Design

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    1/61

    O BJECT O RIEN TED

    AN ALYSIS AN D D ESIG N

    U SIN G TH E U M L

    VERSIO N 4.2

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    2/61

    Objectives: Introduction to

    Object Orientation Understand the basic principles of

    object orientation

    Understand the basic concepts andterms of object orientation and theassociated UML notation

    Appreciate the strengths of objectorientation

    Understand some basic UMLmodeling mechanisms

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    3/61

    Introduction to Object

    Orientation Topics Basic Principles of Object Orientation

    Basic Concepts of Object Orientation

    Strengths of Object Orientation General UML Modeling Mechanisms

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    4/61

    Object Orientation

    Enca

    psulation

    Abs

    traction

    Hierarchy

    Mo

    dularity

    Basic Principles of ObjectOrientation

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    5/61

    Salesperson

    Not sayinghichsalesperson ! j"st a

    salesperson ingeneral###

    C"stomerProd"ct

    Manages Complexity

    W hat is Abstraction?

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    6/61

    Improves Resiliency

    W hat is Encapsulation?

    $ide implementation from clients Clients depend on interface

    $o% does an object encaps"late&hat does it encaps"late&

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    7/61

    Order Processing

    System

    Billing

    Order

    Entry

    Order

    Fulfillment

    Manages Complexity

    W hat is M odularity?

    'he brea(ing "p of something

    comple) into manageable pieces

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    8/61

    Decreasing

    abstraction

    Increasing

    abstraction

    Asset

    RealEstate

    Savings

    BankAccount

    Checking Stock

    Security

    Bond

    Elements at the same level of the hierarchyshould be at the same level of abstraction

    W hat is ierarchy?

    Le*els of abstraction

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    9/61

    Introduction to Object

    Orientation Topics Basic Principles of Object Orientation

    Basic Concepts of Object Orientation

    Strengths of Object Orientation General UML Modeling Mechanisms

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    10/61

    Basic !oncepts of Object

    Orientation Object

    Class

    Attrib"te Operation

    +nterface ,Polymorphism-

    Component

    Pac(age

    S"bsystem

    .elationships

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    11/61

    Basic !oncepts of Object

    Orientation Object

    Class

    Attrib"te Operation

    +nterface ,Polymorphism-

    Component

    Pac(age

    S"bsystem

    .elationships

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    12/61

    Truck

    Chemical Process

    Linked List

    W hat is an Object?

    +nformally/ an object represents an

    entity/ either physical/ concept"al/ orsoft%are Physical entity

    Concept"al entity

    Soft%are entity

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    13/61

    A M ore "or# al $efinition

    An object is a concept/ abstraction/or thing %ith sharp bo"ndaries andmeaning for an application

    An object is something that has0 State

    Beha*ior

    +dentity

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    14/61

    : Professor

    Professor Clark

    a + b = 10

    Professor Clark

    :

    Professor

    ProfessorClark

    Class Name Only

    Object Name Only

    Class and Object Name(stay tuned for classes)

    %epresentin& Objects

    An object is represented as

    rectangles %ith "nderlined names

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    15/61

    Basic !oncepts of Object

    Orientation Object

    Class

    Attrib"te Operation

    +nterface ,Polymorphism-

    Component

    Pac(age

    S"bsystem

    .elationships

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    16/61

    OO Principle: Abstraction

    W hat is a !lass?

    A class is a description of a gro"p ofobjects %ith common properties,attrib"tes-/ beha*ior ,operations-/relationships/ and semantics An object is an instance of a class

    A class is an abstraction in that it0 1mphasi2es rele*ant characteristics S"ppresses other characteristics

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    17/61

    a + b = 10

    Class

    Course

    Properties

    ame

    !ocation

    "ays offered

    Credit hours

    Start time

    End time

    Behavior

    Add a student

    "elete a student

    #et course roster

    "etermine if it is full

    'a# ple !lass

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    18/61

    Professor

    Professor Clark

    a + b = 10

    %epresentin& !lasses

    A class is represented "sing acompartmented rectangle

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    19/61

    Professorname

    empIDcreate( )save( )delete( )change( )

    Class Name

    Attributes

    Operations

    !lass !o# part# ents

    A class is comprised of three sections 'he 3rst section contains the class name

    'he second section sho%s the str"ct"re,attrib"tes-

    'he third section sho%s the beha*ior,operations-

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    20/61

    !lasses of Objects

    $o% many classes do yo" see&

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    21/61

    Objects Class

    Professor Smith

    Professor $ones

    Professor %ellon

    Professor

    The %elationship Bet( een!lasses and Objects

    A class is an abstract de3nition of anobject +t de3nes the str"ct"re and beha*ior of

    each object in the class

    +t ser*es as a template for creatingobjects

    Objects are gro"ped into classes

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    22/61

    Basic !oncepts of Object

    Orientation Object

    Class

    Attrib"te Operation

    +nterface ,Polymorphism-

    Component

    Pac(age

    S"bsystem

    .elationships

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    23/61

    :CourseOering

    num&er ' ()(

    startTime ' *))endTime ' (())

    :CourseOering

    num&er ' ()+startTime ' (,))

    endTime ' (-))

    CourseOering

    num&er

    startTime

    endTime

    Class

    Attribute

    Object

    Attribute Value

    W hat is an Attribute?

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    24/61

    Basic !oncepts of Object

    Orientation Object

    Class

    Attrib"te Operation

    +nterface ,Polymorphism-

    Component

    Pac(age

    S"bsystem

    .elationships

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    25/61

    CourseOering

    addStudent

    deleteStudentgetStartTime

    getEndTime

    Class

    Operation

    W hat is an Operation?

    B i ! t fObj t

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    26/61

    Basic !oncepts of ObjectOrientation

    Object

    Class

    Attrib"te Operation

    +nterface ,Polymorphism-

    Component

    Pac(age

    S"bsystem

    .elationships

    W h ti P l hi ?

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    27/61

    %anufacturer A%anufacturer B

    %anufacturer C

    OO Principle:

    ncapsulation

    W hat is Poly# orphis# ?

    'he ability to hide many di4erent

    implementations behind a singleinterface

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    28/61

    Tu&e

    Pyramid

    Cu&e

    Sha.e

    "ra/

    %ove

    Scale

    Rotate

    00interface11

    Reali2ation relationshi. (stay tuned for realization

    relationships)

    W hat is an Interface?

    +nterfaces formali2e polymorphism

    +nterfaces s"pport 5pl"g6and6play7architect"res

    I t f % t ti

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    29/61

    Tu&e

    Pyramid

    Cu&e

    Sha.e"ra/

    %ove

    Scale

    Rotate

    00interface11

    Tu&e

    Pyramid

    Cu&eSha.e

    Elided/Iconic

    Representation

    (lollipop)

    Canonical

    (Class/Stereoty

    pe)Representation

    (stay tuned for realization

    Interface %epresentations

    B i ! t fObj t

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    30/61

    Basic !oncepts of ObjectOrientation

    Object

    Class

    Attrib"te

    Operation

    +nterface ,Polymorphism-

    Component

    Pac(age

    S"bsystem

    .elationships

    W h ti ! t?

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    31/61

    Source File

    ame

    00E3E11

    E4ecuta&le

    ame

    OO Principle:

    ncapsulation

    W hat is a !o# ponent?

    A non6tri*ial/ nearly independent/

    and replaceable part of a systemthat f"l3lls a clear f"nction in theconte)t of a %ell6de3ned architect"re

    A component may be A so"rce code component

    A r"n time components or

    An e)ec"table component

    00"!!11

    Com.onent

    ameCom.onent

    5nterface

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    32/61

    Basic !oncepts of Object

    Orientation Object Class

    Attrib"te

    Operation

    +nterface ,Polymorphism-

    Component

    Pac(age

    S"bsystem

    .elationships

    W h ti P ) ?

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    33/61

    Package ameOO Principle:

    Modularity

    W hat is a Pac)a&e?

    A pac(age is a general p"rpose mechanism

    for organi2ing elements into gro"ps A model element %hich can contain other

    model elements

    Uses Organi2e the model "nder de*elopment

    A "nit of con3g"ration management

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    34/61

    Basic !oncepts of Object

    Orientation Object Class

    Attrib"te

    Operation

    +nterface ,Polymorphism-

    Component

    Pac(age

    S"bsystem

    .elationships

    W hatis a 'ubsyste# ?

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    35/61

    OO Principles: ncapsulation and Modularity

    00su&system11

    Su&system ame

    5nterfaceInterface

    RealizationSubsystem

    (stay tuned for realization relationship)

    W hat is a 'ubsyste# ? A combination of a pac(age ,can

    contain other model elements- andaclass ,has beha*ior-

    .eali2es one or more interfaces%hich de3ne its beha*ior

    'ubsyste# s and !o# ponents

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    36/61

    Com.onent

    ame

    "esign %odel 5m.lementation %odel

    00su&system11

    Com.onent ame

    Com.onent5nterface

    Com.onent5nterface

    OO Principles: ncapsulation and Modularity

    'ubsyste# s and !o# ponents

    Components are the physical

    reali2ation of an abstraction in thedesign

    S"bsystems can be "sed to

    represent the component in thedesign

    Basic !oncepts ofObject

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    37/61

    Basic !oncepts of ObjectOrientation

    Object

    Class

    Attrib"te

    Operation

    +nterface ,Polymorphism-

    Component

    Pac(age

    S"bsystem

    .elationships

    %elationships

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    38/61

    %elationships

    Association

    Aggregation Composition

    8ependency

    Generali2ation .eali2ation

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    39/61

    Professor 6niversity!or"s for

    Class

    Association

    Association Name

    Professor 6niversity

    EmployerEmployee

    Role Names

    %elationships: Association

    Models a semantic connectionamong classes

    %elationships:A&&re&ation

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    40/61

    Student Schedule

    !ole

    A""re"ation

    #art

    %elationships: A&&re&ation

    A special form of association thatmodels a %hole6part relationshipbet%een an aggregate ,the %hole-and its parts

    %elationships:!o# position

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    41/61

    Student Schedule

    !ole

    A""re"ation

    #art

    %elationships: !o# position

    A form of aggregation %ith strongo%nership and coincident lifetimes 'he parts cannot s"r*i*e the

    %hole9aggregate

    Association:M ultiplicity and

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    42/61

    Association: M ultiplicity and*avi&ation

    M"ltiplicity de3nes ho% many objectsparticipate in a relationships 'he n"mber of instances of one class related to

    ON1 instance of the other class Speci3ed for each end of the association

    Associations and aggregations are bi6directional by defa"lt/ b"t it is often

    desirable to restrict na*igation to onedirection +f na*igation is restricted/ an arro%head is

    added to indicate the direction of the na*igation

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    43/61

    Association: M ultiplicity

    788+

    )88(

    (889

    )889

    (

    9

    Unspeci3ed

    1)actly one

    :ero or more ,many/ "nlimited-

    One or more

    :ero or one Speci3ed range

    M"ltiple/ disjoint ranges

    7 +88;

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    44/61

    Student Schedule$ %&&'

    ultiplicity

    Nai"ation

    E+a# ple: M ultiplicity and

    *avi&ation

    %elationships:$ependency

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    45/61

    Client Su..lier

    #ac*a"e

    ClientPackage Su..lierPackage

    Client Su..lier

    Class

    +ependency

    relations!ip

    +ependency

    relations!ip

    Component

    %elationships: $ependency

    A relationship bet%een t%o model

    elements %here a change in onemayca"se a change in the other

    Non6str"ct"ral/ 5"sing7 relationship

    %elationships:,enerali-ation

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    46/61

    %elationships: ,enerali-ation

    A relationship among classes %here oneclass shares the str"ct"re and9orbeha*ior of one or more classes

    8e3nes a hierarchy of abstractions in%hich a s"bclass inherits from one ormore s"perclasses Single inheritance

    M"ltiple inheritance

    Generali2ation is an 5is6a6(ind of7relationship

    E+a# ple:'in&le Inheritance

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    47/61

    !ccount

    balancena"enu"ber

    #ithdra$%&Create'tate"ent%&

    Checking

    #ithdra$%&

    'avings

    (etInterest%ithdra$%&

    Superclass

    (parent)

    Subclasses

    ,enerali-ation

    Relations!ip

    Ancestor

    +escendents

    E+a# ple: 'in&le Inheritance

    One class inherits from another

    E+a# ple:M ultiple Inheritance

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    48/61

    Air.lane

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    49/61

    Inheritance leverages the similarities among classes

    W hat ,ets Inherited?

    A s"bclass inherits its parent;sattrib"tes/ operations/ andrelationships

    A s"bclass may0 Add additional attrib"tes/ operations/

    relationships

    .ede3ne inherited operations ,"se

    ca"tion#- Common attrib"tes/ operations/

    and9or relationships are sho%n at thehighest applicable le*el in the

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    50/61

    Truck

    tonnage

    #round>ehicle

    /eight

    licenseum&er

    Car

    o/ner

    register? @

    getTa4? @

    Person

    )889

    Trailer

    (Superclass

    (parent)

    Subclass

    generalization

    si2e

    E+a# ple: W hat ,ets Inherited

    %elationships:%eali-ation

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    51/61

    Com.onent

    Interace

    6se Case 6seCase Reali2ation

    Elided form

    Class

    InteraceSu&system

    Interace

    Canonical form

    %elationships: %eali-ation

    One classi3er ser*es as the contract

    that the other classi3er agrees tocarry o"t

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    52/61

    !lass $ia&ra# for the 'alesE+a# ple

    Sales.erson Product

    Sale

    Cor.orate

    Customer

    5ndividual Truck

    >ehicle

    Train

    seller &uyer item sold shi..ing mechanism

    ff f i h

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    53/61

    Effect of %e.uire# ents !han&e'uppose )ou need ane$ t)pe o shipping

    vehicle ***

    Sales.erson Product

    Sale

    Cor.orate

    Customer

    5ndividual Truck

    >ehicle

    Train

    seller &uyer item sold shi..ing mechanism

    Change involves adding a ne$ subclass

    Air.lane

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    54/61

    Introduction to Object

    Orientation Topics Basic Principles of Object Orientation Basic Concepts of Object Orientation

    Strengths of Object Orientation General UML Modeling Mechanisms

    'tereotypes

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    55/61

    00&oundary11%yBoundaryClass

    %yBoundaryClass

    'tereotypes

    Classify and e)tend the UMLnotational elements

    8e3ne a ne% model element interms of another model element

    May be applied to all modelingelements

    .epresented %ith name in g"illemets

    or as a di4erent icon

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    56/61

    00&oundary11

    00&oundary11

    00trace11

    Processor #1

    >Processor??

    'hese create ne% symbols "singacc"stomed graphics@

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    57/61

    There can &e u. to one

    %aintainScheduleForm .er

    user session8%aintainScheduleForm

    *otes

    A note can be added to any UMLelement

    Notes may be added to add moreinformation to the diagram

    +t is a =dog eared; rectangle

    'he note may be anchored to anelement %ith a dashed line

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    58/61

    PersistentClass

    .ersistence anO&Dect : ClassA

    location'server

    Ta&&ed /alues

    1)tensions of the properties/ orspeci3c attrib"tes/ of a UML element

    Some properties are de3ned by UML Persistence

    Location ,e@g@/ client/ ser*er-

    Properties can be created by UML

    modelers for any p"rpose

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    59/61

    Professor "e.artmentember

    +epartment .eadsubset0

    $&&'

    $

    $

    $

    !onstraints

    S"pports the addition of ne% r"les ormodi3cation of e)isting r"les

    'his notation is "sed to capt"re t%o relationships bet%een Professor6type objects and 8epartment6type objects %here one relationship is a s"bset of another@

    Sho%s ho% UML can be tailored to correctly modeling e)act relationships@

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    60/61

    (continued)

    %evie(: Introduction to Object

    Orientation hat are the fo"r basic principles ofobject orientation& Pro*ide a briefdescription of each@

    hat is an Object and %hat is a Class&hat is the di4erence bet%een them&

    hat is an Attrib"te&

    hat is an Operation&

    hat is an +nterface& hat isPolymorphism&

    hat is a Component&

  • 7/23/2019 Lec23 & 24_Object Oriented Analysis and Design

    61/61

    %evie(: Introduction to Object

    Orientation 0cont12 hat is a Pac(age& hat is S"bsystem& $o% does it relate to a

    Component& $o% does it relate to a pac(age&

    $o% does it relate to a class& Name the basic UML relationships and

    describe each@

    8escribe the strengths of object orientation@

    Name and describe some general UMLmechanisms@

    hat are stereotypes& Name some common"ses of stereotypes@