02_UML2Fundamentals4RhapsodyPt1

Embed Size (px)

Citation preview

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    1/12

    Essentials of IBMRationalRhapsodyfor Software Engineers

    UML v2.1 Fundamentals

    Courtesy of IBM Corporation Academic License

    2

    What is UML?

    Unified Modeling Language

    Comprehensive full life-cycle 3rd Generation modeling languageStandardized in 1997 by the OMG (Object Management Group)

    Created by a consortium of 12 companies from various domains

    IBM a key contributor to behavioral modeling

    Incorporates state of the art Software and Systems A&D concepts

    Matches the growing complexity of real-time systemsLarge scale systems, Networking, Web enabling, Data management

    Extensible and configurable

    Unprecedented inter-disciplinary market penetration

    UML 2.1 is latest version

    3

    UML 2 diagrams

    CommunicationDiagrams

    SequenceDiagrams

    InteractionDiagrams

    ClassDiagrams

    Deployment

    Diagrams

    ComponentDiagrams

    ObjectDiagrams

    StructuralDiagrams

    state chart

    Diagrams

    TimingDiagrams

    ActivityDiagrams

    BehavioralDiagrams

    Use CaseDiagrams

    PackageDiagramsStructure

    Diagrams

    InteractionDiagrams

    4

    Use case diagram

    This diagram shows what the system does and who usesit.

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    2/12

    5

    Sequence diagram

    Sequence Diagrams show how instances communicateover time.

    6

    Class diagram

    Class diagrams show classes and relations betweenthem.

    7

    Object diagram

    Object Diagrams show instances of classes and showwhich ones are linked to others at run time.

    8

    Structure diagram

    This diagram shows the internal structure of classes.

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    3/12

    9

    state chart diagram

    state charts are used when you need to wait untilsomething happens before going to a different state.

    10

    Activity diagram

    Activity diagrams are used todescribe behavior for operations,classes, or use cases. As soon

    as one activity finishes, the nextone starts.

    11

    Package diagram

    A package is similar to a folder and is used to organisethe UML model elements.

    12

    Communication diagram

    This used to be known as a Collaboration Diagramand issimilar to a Sequence Diagram, but generally lesspopular.

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    4/12

    13

    Component diagram

    A component diagram shows how components such as

    .exe, .dll, .lib, are interconnected.

    14

    Deployment diagram

    A Deployment Diagram shows how UML artifacts aredeployed onto hardware nodes.

    15

    Timing diagram

    Time

    Sending::Low

    Sending::High

    Receving::Low

    Receiving::High

    Sending

    ReceivingIdle

    Coil Driver

    Transceiver

    transmit(value)

    Tristate

    Monitor

    Initializing

    Acquiring

    Reporting

    Idle

    send(value)

    send(value)

    tm(bitTime)

    {1 ms +/- 0.2ms}

    {3 ms +/- 0.2ms}

    evDone

    The Timing Diagram focuses on changing conditionswithin and among objects on a linear time axis.

    16

    Interaction overview diagram

    sdsd

    ref

    dispatch_event

    An Interaction Diagram is a mixture of an ActivityDiagram and several Sequence Diagrams.

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    5/12

    17

    How does UML apply to real-time?

    Real-Time UML is standard UML

    Although there have been a number of calls to extend UML forthe real-time domain experience had proven this is notnecessary. Bran Selic, Communications of the ACM, Oct 1999

    Real-time and embedded applications

    Special concerns about quality of service (QoS)

    Special concerns about low-level programming

    Special concerns about safety and reliability

    Real-time UML is about applying the UML to meet thespecialized concerns of the real-time and embedded

    domains

    18

    How do you describe structure using UML?

    19

    An object is one of the common building blocks in aUML model. It can represent a system, a subsystem ora specific software class in a programming language.

    Several definitions are available:An object is a real-world or conceptual thing that has

    autonomy.

    An object is a cohesive entity consisting of data and theoperations that act on those data.

    An object is a thing that has an interface that enforcesprotection of the encapsulation of its internal structure.

    What is an object ?

    20

    What is an object ?

    Every object has:

    Responsibilities:

    What does the object do? Why does it exist?

    Attributes:

    This is the internal data and can either be fixed in value orcan vary in value.

    Behaviors:

    These are actions performed by the object to fulfil itsresponsibilities.

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    6/12

    21

    A radio

    Responsibilities:

    Allow the user to listen to desired radio frequency

    Attributes:

    Wavelength

    Frequency

    Volume

    Behaviors:

    Tune to a frequency

    Store / Recall a frequency

    Change volume

    Switch on / off

    22

    A digital camera

    Responsibilities:

    Take digital photos

    Attributes:

    Available Memory

    Picture Resolution

    Battery Level

    Behaviors:

    Select Resolution

    Focus

    Take Photo

    Upload Photos

    23

    A microwave oven

    Responsibilities?

    Attributes?

    Behaviors?

    24

    Objects can be

    Software thingsOccupy memory at some point in time

    For example, CustomerRecord, ECGSample, Window, Font

    Electronic thingsOccupy physical space at some point in time

    For example, Thermometer, LCDDisplay, MotionSensor, DCMotor

    Mechanical thingsOccupy physical space at some point in time

    For example, WingSurface, Gear, Door, HydraulicPress

    Chemical thingsOccupy physical space at some point in time

    For example, Battery, GasMixture, Halothane

    System thingsOccupy physical space at some point in time

    For example, PowerSubsystem, RobotArm, Space Shuttle

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    7/12

    25

    All objects are unique even if their attributes are the sameas another.

    For example, in this room, there are probably many

    mobile phones, of which several might well be identical.Even if they are identical, they are all unique.

    Object identity

    Andysphone

    Colinsphone

    Iansphone

    26

    Objects have generally two differentviews:Public view:

    This is the view that can be seen fromoutside of the object.

    Private view: This is the internal only view, access is

    controlled and the details are hiddenfrom the outside world.

    Object views

    27

    Object interface

    The Public view of an object is the interface that the object exposesto the outside world and which other objects can use to communicatewith it.

    Objects contain their own attributes and generally do not allow otherobjects to directly manipulate these attributes.

    If other Objects need access to the attributes, then the objectprovides public operations (known as getters and setters) tomanipulate these attributes.

    This allows the freedom to change the type of the attribute without theclients knowing about it or indeed having to make any changes. Allthat is needed is to modify the getter and setter to manipulate thenew attribute type.

    Getters and Setters aresometimes called AccessorsandMutators.

    28

    Object attributes

    Attributes are typedvalues holding information knownto the object, for example:

    value: int

    patientName: string

    All objects of the same type have the same set ofattributes but different copies(hence they may havedifferent values).

    Attributes are primitive in structure and behavior:

    If they are rich, then they should be themselves objects.

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    8/12

    29

    Object operations

    Objects execute operations to implement behavior:

    Operations are primitive behaviors such as:

    ++x

    y = sin(x)^2 + cos(x)^2 z = mySensor->getValue()

    Operations can manipulate the attributes, call otheroperations.

    Operations can be invoked from other objects as well asfrom a state chart or activity diagram attached to theobject.

    30

    UML class

    A Class is the definitionor specificationof an object.

    An object is an instanceof a class.

    An object has the attributes and behaviors defined by its class.

    A class can be shown on a Class Diagram in one of many ways.

    On some diagrams, you might want to show just the name of the class.

    Sometimes, you might want to show just the operations; other times, youmight want to show all attributes and all operations.

    Attributes

    Operations

    Name

    31

    UML object

    As with a class, an Object (also known as an Instance)can also be shown on a Class/Object Diagram in manyways:

    It is not necessaryto show everyattribute, everyoperation, visibility,

    Attributevalues at aspecific

    instance intime

    Object name Class name

    Implicitobject

    Multiplicity

    32

    Multiplicity

    When showing Objects, you need to indicate how manyobjects there are.

    This is done with the Multiplicity, which most of the time is1.

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    9/12

    33

    Visibility defined

    Attributes and Methods or Operations are featuresof a class.

    Features have the visibility adornments:

    + public

    Accessible by any client of the class.

    # protected Accessible only from within the same class or subclasses.

    - private Accessible only from within the same class.

    Rather than using thesesymbols, RationalRhapsody uses moregraphical ones which areeasier to understand.

    34

    Constructors and destructors

    Every Class has a couple of special operations allowingObjects to be constructed / destroyed.

    A constructor is always called when an Object is created

    and generally initializes its attributes. A destructor is always called when the Object is

    destroyed and ensures that any allocated resources areproperly returned.

    Constructor

    Destructor

    35

    Staticandabstract operations

    A static operation is shown underlined.

    An abstract operation is shown in italic.

    36

    Exercise 1

    What are the attributes, operations and responsibilities ofthe following?

    Solutions will be discussed in the tute session.

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    10/12

    37

    Object discovery strategies

    38

    Object discovery strategies

    Identify the nouns

    Services to be performed

    Transactions

    Physical devices

    Key concepts

    Persistent data

    Control Element

    Walking through scenarios

    Experience

    39

    Identify the nouns

    Find nouns and noun phrases in the problem statement

    Provides a first-cut list of potential classes and objects

    Discovers:

    Objects of interest

    Uninteresting objects

    Attributes What do Ido?

    What do I

    know?

    What are my

    responsibilities?

    40

    Services to be performed

    Service providers are usually passive servers

    May provide:

    Strategy

    Algorithm

    Creation of complex objects

    Examples:

    Measurement

    Filter

    CommandFactory

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    11/12

    41

    Physical devices

    Very common approach in embedded systems.

    Devices are often modeled as classes and objects.

    ECG Example:

    HeartA/D converter

    Switch

    Button

    Physical devices are modeled either asinterfaces to the actual hardware (actualbehavior is in the hardware, the software class

    provides a means for objects to talk to it) or, lesscommonly, simulations (simulates actualhardware behavior).

    42

    These are the fundamental abstractions in the domain.

    These concepts often have no physical manifestation.

    Examples:

    UI Domain Window, Icon, Cursor, Tool Bar,

    Robotics Task plan

    Banking Account

    OS Thread

    Navigation Waypoint

    Key concepts

    43

    Transactions

    Transactions are objects arising from the need tomanage or track the interaction of other objects.

    Transaction objects may be:

    Persistent: require long term storage

    Volatile: disappear when the transaction completes

    Examples:

    Message

    Command

    44

    Persistent information

    Information that must be stored for later retrieval is eitherobjects or attributes.

    Examples:

    A medical device must maintain an alarm history for later

    reportingWaveform data must be maintained for 20s buffer to be routed

    to a chart recorder

    Access passwords and user IDs

    Calibration constants

  • 8/7/2019 02_UML2Fundamentals4RhapsodyPt1

    12/12

    45

    Control elements

    Entities that control other objects

    A specific type of causal agent

    Examples:

    Transaction controller in database

    Audio and video synchronizer

    Autopilot

    Clothes washer cycle controller

    A Causal agent is any entitythat produces an effect or isresponsible for events orresults.

    46

    Walking through scenarios

    Scenarios consist of objects interacting in specific waysover time.

    Allow testing of class and object models:Are all necessary facilities and services available?

    Do the objects attributes and behaviors support itsresponsibilities?