Holt UML Slides

Embed Size (px)

Citation preview

  • 8/12/2019 Holt UML Slides

    1/25

    Introduction to UML:

    Unified Modeling Language

    Ric Holt

    U Waterloo, March 2009CS246

  • 8/12/2019 Holt UML Slides

    2/25

    2

    Example UML ClassDiagram

    http://www.agiledata.org/images/oo101ClassDiagram.gif

  • 8/12/2019 Holt UML Slides

    3/25

    UML: Unified Modeling

    Language The Unified Modeling Language (UML) is

    a family of graphical notations that help

    in describing and designing softwaresystems, particularly those built using

    object-oriented (OO) style [Martin Fowler

    in UML Distilled]

  • 8/12/2019 Holt UML Slides

    4/25

    History

    Design notation of various kinds used sinceprogramming began:

    Flow charts, Pseudo code, Structure Diagrams

    With advent of OO, many conflicting notations(1980s , 1990s)

    These notations were combined and unified(late

    1990s) UML extensively taught in universities

    (2000 - now).

  • 8/12/2019 Holt UML Slides

    5/25

    3 Ways to Use UML

    (Both forward & reverse engineering)1) Sketch e.g. at white board

    Most common, quick and informal

    Communication & understanding2) Blueprint

    Detailed design, implemented by programmer

    May have tools supporting diagramming3) Programming Language

    Tools translate diagrams to executable code

  • 8/12/2019 Holt UML Slides

    6/25

    Fowler says

    Almost all the time, my use of the UML is

    as sketches.

    Im not a fan of detailed forward

    engineeredblueprints.

    I see the UML as aprogramming language

    as a nice idea but doubt that it will ever seesignificant usage.

  • 8/12/2019 Holt UML Slides

    7/25

    Savitch say:

    Todays candidate for a graphical

    representation formalism is the UML. It

    is too early to say whether or not the UMLwill stand the test of time [Savitch,

    Absolute C++, 3rd Edition]

  • 8/12/2019 Holt UML Slides

    8/25

    Software Lifecycle:

    UML Can Be Used at Various Stages

    Analysis: OOA

    What is system to do? What services is it to

    provide? Provide requirements for designer.

    Design: OOD

    What will be the parts & structure of the

    system? How will they interact? Provideblueprint for programmer.

    Programming: OOP

  • 8/12/2019 Holt UML Slides

    9/25

    13 (!!) Kinds of UML Diagrams

    1) Activity

    2) Class

    3) Communication

    4) Component

    5) Component structure

    6) Deployment7) Interaction

    8) Object

    9) Package

    10) Sequence

    11) State machine

    12) Timing

    13) Use case

  • 8/12/2019 Holt UML Slides

    10/25

    Classification of UML Diagrams

    (Part 1 of 2)

    Structure

    1) Class diagram

    2) Component diagram (cmpts can be independently purchasedand replaced)

    3) Component structure diagram

    4) Deployment diagram (what goes on what machine & place)

    5) Object diagram6) Package diagram (pkg = group of classes, e.g. namespace)

  • 8/12/2019 Holt UML Slides

    11/25

    Classification of UML Diagrams

    (Part 2 of 2)

    Behavior

    7) Activity diagram (flow chart)

    8) Use Case diagram (scenarios for use of system)9) State Machine diagram

    10) Sequencediagram

    11) Communication diagram (data flow diagrams)

    12) Interaction diagram (activity + sequence diagrams)

    13) Timing diagram

  • 8/12/2019 Holt UML Slides

    12/25

    Class Diagrams

  • 8/12/2019 Holt UML Slides

    13/25

    13

    Example UML ClassDiagram

    http://www.agiledata.org/images/oo101ClassDiagram.gif

  • 8/12/2019 Holt UML Slides

    14/25

    Class

    Class Name

    Attribute: type

    Operation(arg list) : return type

    Abstract operation

    Various parts are optional

  • 8/12/2019 Holt UML Slides

    15/25

    Instance Specification

    (Object)

    ObjectName: Class Name

    Attribute: type

    Operation(arg list) : return type

    Abstract operation

    Various parts are optional

  • 8/12/2019 Holt UML Slides

    16/25

    Role of A

    Role of B

    Kinds of Edges

    Class A Class B

    Source TargetRole name

    Client Supplier

    Dependency

    Navigability

    Association

    Role name

    There are other kinds of edges

  • 8/12/2019 Holt UML Slides

    17/25

    Multiplicities on Edges

    (Cardinalities)

    1 Exactly one

    * Many (any number)

    0..1 Optional (zero or one)

    m..n Specified range

    {ordered}* Ordered

  • 8/12/2019 Holt UML Slides

    18/25

    Generalization

    (Inheritance)

    Supertype

    Subtype 1 Subtype 2

  • 8/12/2019 Holt UML Slides

    19/25

    Note

    (Comment)

    Comment

    about an item

    Some

    item eg

    class

  • 8/12/2019 Holt UML Slides

    20/25

    Sequence Diagrams

  • 8/12/2019 Holt UML Slides

    21/25

    Example for Sequence Diagram

    [Fowler]

    We have an order and are going to invoke acommand on it to calculate its price. To do

    that, the order needs to look at all the lineitems on the order and determine theirprices, which are based on the pricing rulesof the order lines products. Having done

    that for all the line items, the order thenneeds to compute an overall discount, whichis based on rules tied to the customer.

  • 8/12/2019 Holt UML Slides

    22/25

    Example for Sequence Diagram

    [Fowler]

    We have an orderand are going to invoke acommand on it to calculate its price. To do

    that, the order needs to look at all the lineitemson the order and determine theirprices, which are based on the pricing rulesof the order linesproducts. Having done

    that for all the line items, the order thenneeds to compute an overall discount, whichis based on rules tied to the customer.

  • 8/12/2019 Holt UML Slides

    23/25

    Example Sequence Diagram

    anOrder anOrderLine aProduct aCustomer

    calculatePricegetQuantity

    getProduct

    getPricingDetails

    getBasePrice

    calculateDiscounts

    getDiscountInfo

    aProductFound

    message

    Participant Lifeline

    Return

    Activation

    Self call

    Message

  • 8/12/2019 Holt UML Slides

    24/25

    Elements of Sequence Diagrams

    There is also notation for loops, conditions, etc.

    Name: Class

    New object

    Create

    Message

    Return

    Delete

    Self-call

  • 8/12/2019 Holt UML Slides

    25/25

    Diagram Size

    (Cognitive Limit)

    Generally, a diagram is not useful if it

    contains more than about 25 boxes