Visual Modeling & Unified Modeling Language(UML)CopyFINAL

download Visual Modeling & Unified Modeling Language(UML)CopyFINAL

of 35

Transcript of Visual Modeling & Unified Modeling Language(UML)CopyFINAL

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    1/35

    Object OrientedObject Oriented

    Analysis AndAnalysis And

    design Throughdesign ThroughUMLUML

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    2/35

    This sessionThis session

    Introduction to modelingIntroduction to modeling Class diagramsClass diagrams

    Use case diagramsUse case diagrams

    Sequence DiagramsSequence Diagrams

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    3/35

    Introduction to ModelingIntroduction to Modeling

    What is a model?What is a model?

    A model is a simplification of realty.A model is a simplification of realty.Why do we model?Why do we model?

    We build models so that we can betterWe build models so that we can better

    understand the system we areunderstand the system we aredevelopingdeveloping

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    4/35

    How can you realize theHow can you realize the

    benefits of modeling?benefits of modeling?

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    5/35

    What is the UMLWhat is the UML

    The UML is the standard language forThe UML is the standard language for

    Visualizing,Visualizing, Specifying,Specifying,

    Constructing, andConstructing, and

    DocumentingDocumenting

    the artifacts of a software-intensivethe artifacts of a software-intensive

    systemsystem

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    6/35

    RELATIONSHIPS

    DIAGRAMS

    THINGS

    STRUCTURAL

    BEHAVIORAL

    GROUPING

    ANNOTATIONAL

    DEPENDENCY

    ASSOCIATION

    GENARALIZATION

    REALIZATION

    1. CLASS

    2. OBJECT

    3. COMPONANT

    4. USE CASE

    5. SEQUENCE

    6. COLLOBORATION

    7. ACTIVITY

    8. AND OTHERS

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    7/35

    All the modeling techniquesAll the modeling techniques

    in briefin briefSequence

    Diagrams

    Collaboration

    diagrams

    State

    MachineDiagrams

    Activity

    Diagrams

    Deployment

    Diagrams

    ComponentDiagrams

    Object

    Diagrams

    Class

    diagrams

    Use case

    diagrams

    UML

    MODELS

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    8/35

    Classification of UMLClassification of UML

    Structural model viewStructural model view

    1) class diagrams1) class diagrams

    2) object diagrams2) object diagrams

    user model viewuser model view

    1) use case diagrams1) use case diagrams

    Behavioral model viewBehavioral model view

    1) sequence diagrams1) sequence diagrams

    2) collaboration diagrams2) collaboration diagrams

    3) state machine diagrams3) state machine diagrams

    4) activity diagrams4) activity diagrams

    Implementation model viewImplementation model view

    1)component diagrams1)component diagrams

    Environment model viewEnvironment model view

    1) deployment diagrams1) deployment diagrams

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    9/35

    Structural modelStructural model

    viewviewClass DiagramsClass Diagrams

    Object DiagramsObject Diagrams

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    10/35

    DEPENDENCY GENARALIZATIO

    REALIZATION ASSOCIATION

    Class diagram

    Structure &behavior

    Relationships Multiplicity &Navigation

    ne Class uses the

    formation of otherOne class specifiesA contract that other

    Class will carru out

    Objects of one thing areConnected to objects

    Of another

    Relationship betweenGeneral kind of class

    And a more specificKind of class

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    11/35

    Structure of a ClassStructure of a Class

    A class is a collection ofA class is a collection ofobjects with commonobjects with commonstructure, commonstructure, commonbehavior, commonbehavior, commonrelationships andrelationships andcommon semanticscommon semantics

    Classes should be namedClasses should be namedusing the vocabulary ofusing the vocabulary ofthe domainthe domain Naming standards shouldNaming standards should

    be createdbe created e.g., all classes aree.g., all classes are

    ClassNameClassName

    AttributesAttributes

    OperationsOperations

    ResponsibiliResponsibili

    tiesties

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    12/35

    Operations andOperations and

    AttributesAttributes

    OperationsOperations ::The behavior of a class isThe behavior of a class isrepresented by its operationsrepresented by its operations

    AttributesAttributes ::The structure of a class isThe structure of a class isrepresented by its attributesrepresented by its attributes

    ResponsibilitiesResponsibilities:: It is a contract or anIt is a contract or anobligation of a classobligation of a class..

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    13/35

    Advanced RelationshipsAdvanced Relationships

    Ag gregatio ng gregatio n :: It is a special kind of association and is used when oneIt is a special kind of association and is used when oneclass (whole) consists of 1 or more smaller classes (parts). It shows has-aclass (whole) consists of 1 or more smaller classes (parts). It shows has-arelationship between the whole and its parts.relationship between the whole and its parts.

    Com pos iti onom pos iti on :: This specifies that the lifetime of the partThis specifies that the lifetime of the partclassifier is dependent on the lifetime of the wholeclassifier is dependent on the lifetime of the wholeclassifierclassifier

    Inh eri tan cenh eri tan ce :: There are two ways to findThere are two ways to findinheritance:inheritance:

    Gene rali zatio nene rali zatio n :: As you move "up" the hierarchy, you achieveAs you move "up" the hierarchy, you achievegreater generalization . You move up toward Mammal to generalize thatgreater generalization . You move up toward Mammal to generalize that

    dogs, cats, and horses all bear live youngdogs, cats, and horses all bear live young.. Sp eci aliz ati onp eci aliz ati on :: As you move "down" the hierarchy you specialize.As you move "down" the hierarchy you specialize.

    Thus, the cat specializes Mammal in having claws (a characteristic) andThus, the cat specializes Mammal in having claws (a characteristic) andpurring (a behaviorpurring (a behavior

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    14/35

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    15/35

    Multiplicity and NavigationMultiplicity and Navigation

    MultiplicityMultiplicity defines howdefines howmany objects participate inmany objects participate ina relationshipa relationship Multiplicity is theMultiplicity is the

    number of instances ofnumber of instances ofone class related toone class related to

    ONE instance of theONE instance of theother classother class

    For each associationFor each associationand aggregation, thereand aggregation, thereare two multiplicityare two multiplicitydecisions to make: onedecisions to make: one

    for each end of thefor each end of therelationshiprelationship

    IfIfnavigationnavigation is restricted,is restricted,an arrowhead is added toan arrowhead is added to

    indicate the direction ofindicate the direction ofthe navigationthe navigation

    IndicatIndicat

    ororMeaningMeaning

    0..10..1 Zero or oneZero or one

    11 One onlyOne only

    0..*0..* Zero or moreZero or more

    1..*1..* One or moreOne or more

    nn OnlyOnly nn ((nn > 1)> 1)

    0..n0..n Zero toZero to nn ((nn>>

    1)1)

    1..n1..n One toOne to nn ((nn >>

    1)1)

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    16/35

    A small Work outA small Work out

    Try to make Class diagram for aTry to make Class diagram for abanking system ?????????banking system ?????????

    NOWNOW

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    17/35

    Building a systemBuilding a system

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    18/35

    user model viewuser model view

    Use case DiagramsUse case Diagrams

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    19/35

    RelationshipsBetween Actors

    & usecases

    Use CaseDiagrams

    Behavior orUSE CASEActor

    What's up inWhat's up in

    usecases??????usecases??????

    An actor is aAn actor is aperson,person,

    organization,organization,

    or externalor external

    system thatsystem that

    plays a role inplays a role in

    one or moreone or more

    interactionsinteractionswith yourwith your

    I t d ti t USE CASEI t d ti t USE CASE

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    20/35

    Introduction to USE CASEIntroduction to USE CASE

    diagramsdiagrams

    What is a use case diagram??What is a use case diagram??AA use case diagramuse case diagram is a type ofis a type ofbehavioral diagrambehavioral diagram..whose purpose is to present a graphical overview of thewhose purpose is to present a graphical overview of the

    functionality provided by a system in terms of actors, theirfunctionality provided by a system in terms of actors, theirgoals (represented as use cases), and any dependenciesgoals (represented as use cases), and any dependencies

    between those use casesbetween those use cases

    What do they represent?What do they represent?

    They represent the functionality of the system from usersThey represent the functionality of the system from userspoint of viewpoint of view

    who will be using the system?who will be using the system?ACTORACTOR

    what will they be using it to do? ?what will they be using it to do? ?

    USECASEUSECASE

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    21/35

    Who is an actor???Who is an actor???

    For example, a bank cardholder might need to use an ATM to getFor example, a bank cardholder might need to use an ATM to getcash out of their account. It is as simple as that.cash out of their account. It is as simple as that. Actors don't have to be people. They can be other systems. ForActors don't have to be people. They can be other systems. For

    example, the ATM may need to connect to the cardholder's bank.example, the ATM may need to connect to the cardholder's bank.External systems that interact in a use case are also actors.External systems that interact in a use case are also actors.

    actor system goal

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    22/35

    What Is A Use Case Scenario?What Is A Use Case Scenario?

    Some examples ofSome examples ofuse case scenariosuse case scenarios.. When a cardholder tries to withdraw cashWhen a cardholder tries to withdraw cash

    from an ATM, it doesn't always necessarilyfrom an ATM, it doesn't always necessarilyturn out the same way.turn out the same way. Sometimes he gets his money.Sometimes he gets his money. Other times he might have insufficient funds.Other times he might have insufficient funds. Or the ATM may be out of cashOr the ATM may be out of cash

    The outcome is different, depending onThe outcome is different, depending oncircumstances, but they all relate to the samecircumstances, but they all relate to the samefunctional goal . that is, they're all triggered byfunctional goal . that is, they're all triggered bythe same need and all have the same startingthe same need and all have the same startingpoint.point.

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    23/35

    Capturing Use Case Scenarios withCapturing Use Case Scenarios with

    Essential Use Case DescriptionsEssential Use Case Descriptions Dont go into technicalDont go into technical

    aspect of the designaspect of the design We first need toWe first need to

    understand what theunderstand what thebusiness logicbusiness logic of theof theinteractions are, so weinteractions are, so wecan focus on satisfyingcan focus on satisfyingthe business goal of thethe business goal of theuse case.use case.

    Instead of saying theInstead of saying theuser presses the enteruser presses the enterbutton, we say the userbutton, we say the userconfirms their choice, forconfirms their choice, forexample.example.

    split the actions intosplit the actions intocolumns, one for eachcolumns, one for each

    actor and one for theactor and one for thesystem. Then we cansystem. Then we cansee at a glance notsee at a glance notonly the order ofonly the order ofevents in a use caseevents in a use casescenario, but alsoscenario, but alsoexactly who is doingexactly who is doingwhat.what.

    AnAn essential use caseessential use caseclearly shows theclearly shows the orderorderof eventsof events and theand the

    select withdrawal option

    displaydisplay

    withdrawalwithdrawal

    optionsoptionsspecifyspecifyamountamount

    check card holdercheck card holder

    hashas

    Sufficient fundsSufficient fundseject cardeject card

    prompt cardholder to takeprompt cardholder to take

    cardcardtake cardtake card

    dispensedispense

    amountamountprompt cardholder to takeprompt cardholder to take

    cashcashtake cashtake cashdebit cardholdersdebit cardholders

    accountaccountthank cardholderthank cardholder

    display welcome and awaitdisplay welcome and awaitnext holdernext holder

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    24/35

    Usecase1

    Usecase2

    actor

    Depiction of actor and usecase

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    25/35

    Remember that use case designsRemember that use case designs

    aren't the same thing asaren't the same thing as

    requirements. These are high-requirements. These are high-

    level interaction designs. if welevel interaction designs. if wemix them up with realmix them up with real

    requirements stuff the systemrequirements stuff the system

    really has to do ,then we can getreally has to do ,then we can getbogged down in the designbogged down in the design

    decisions we make early on.decisions we make early on.

    WARNINGWARNING

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    26/35

    Documenting Use CasesDocumenting Use Cases

    A flow of events document isA flow of events document iscreated for each use cases Writtencreated for each use cases Writtenfrom an actor point of viewfrom an actor point of view

    Details what the system mustDetails what the system mustprovide to the actor when the useprovide to the actor when the usecases is executedcases is executed

    Typical contentsTypical contents How the use case starts and endsHow the use case starts and ends Normal flow of eventsNormal flow of events Alternate flow of eventsAlternate flow of events Exceptional flow of eventsExceptional flow of events

    e at ons ps etween

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    27/35

    e at ons ps etweenUse Cases

    Including UseCases: When twoor more use casesinclude the flow of

    another use case,they are said toinclude that usecase's flow.

    Extending Use

    Cases:relationshipmeans that theflow of the

    extending use

    Check tutor availa

    Book assesment

    Book lesson

    View Product

    Review Product

    Check Login

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    28/35

    Summary of use casesSummary of use cases

    1. Identify your actors: who will be using the system?2. Identify their goals: what will they be using the

    system to do?3. Identify key scenarios: in trying to achieve a specific

    goal, what distinct outcomes or workflows might we

    need to consider?4. Describe in business terms the interactions between

    the actor(s) and the system for a specific scenario5. Create a UI prototype that clearly communicates the

    scenario to technical and

    6. non-technical stakeholders7. Do a high-level OO design for the scenario8. Implement the design in code9. Get feedback from your users . ideally through

    structured acceptance testing

    10. Move on to the next scenario or use case (.rinse andrepeat.)

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    29/35

    A small Work outA small Work out

    Try to make Use case diagram for aTry to make Use case diagram for abanking system ?????????banking system ?????????

    NOWNOW

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    30/35

    Behavioral ModelBehavioral Model

    ViewView1.1. Sequence DiagramsSequence Diagrams

    2.2. Collaboration DiagramsCollaboration Diagrams

    3.3. State Machine DiagramsState Machine Diagrams4.4. Activity DiagramsActivity Diagrams

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    31/35

    Sequence DiagramsSequence Diagrams

    The sequence diagram is used primarily toThe sequence diagram is used primarily to

    show the interactions between objects inshow the interactions between objects in

    the sequential order that thosethe sequential order that those

    interactions occur.interactions occur. useful to communicate how the businessuseful to communicate how the business

    currently works by showing how variouscurrently works by showing how various

    business objects interact.business objects interact.

    business-level sequence diagram can bebusiness-level sequence diagram can be

    used as a requirements document toused as a requirements document to

    communicate requirements for a futurecommunicate requirements for a future

    system implementation.system implementation.

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    32/35

    Notation BasicsNotation Basics

    Lifelines:Lifelines: Lifelines are drawn as a box with a dashed lineLifelines are drawn as a box with a dashed linedescending from the center of the bottom edge .The lifeline'sdescending from the center of the bottom edge .The lifeline's

    name is placed inside the box.name is placed inside the box.

    Messages:Messages: The first message of a sequence diagramThe first message of a sequence diagramalways starts at the top and is typically located on the left side ofalways starts at the top and is typically located on the left side of

    the diagram for readability. Subsequent messages are then addedthe diagram for readability. Subsequent messages are then added

    to the diagram slightly lower then the previous message.to the diagram slightly lower then the previous message.

    Guards:Guards: Guards are used throughout UML diagrams toGuards are used throughout UML diagrams to

    control flow.control flow.When modeling object interactions, there will beWhen modeling object interactions, there will betimes when a condition must be met for a message to be sent totimes when a condition must be met for a message to be sent to

    the object.the object.

    Alternatives :Alternatives : Alternatives are used to designate aAlternatives are used to designate a

    mutually exclusive choice between two or more messagemutually exclusive choice between two or more messagesequences. Alternatives allow the modeling of the classic "if thensequences. Alternatives allow the modeling of the classic "if then

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    33/35

    Life lines

    Messages

    Guards

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    34/35

    Alternative

  • 8/14/2019 Visual Modeling & Unified Modeling Language(UML)CopyFINAL

    35/35

    A small Work outA small Work out

    Try to make Sequence diagram for aTry to make Sequence diagram for abanking system ?????????banking system ?????????

    NOWNOW