Side 1 - PowerPoint PPT Presentation

1 / 56
About This Presentation
Title:

Side 1

Description:

Using UML in a development process. From model to implementation - Mapping to Java. ... joined Rational, adding elements from his method OOSE - in particular Use-Case. ... – PowerPoint PPT presentation

Number of Views:256
Avg rating:3.0/5.0
Slides: 57
Provided by: home86
Category:
Tags: oose | side

less

Transcript and Presenter's Notes

Title: Side 1


1
Introduction to UML
  • Carsten Helgesen
  • Department of Computer Engineering
  • Bergen University College
  • Bergen, Norway

2
Outline
  • Object oriented concepts.
  • Unified Modelling Language - UML
  • History.
  • The various UML diagrams.
  • Using UML in a development process.
  • From model to implementation - Mapping to Java.

3
The object oriented approach
Object Identity Behaviour State
4
Classes Java-like example
  • class Person attributes name String
  • address String
  • birthDate Date
  • methods print() age() Integer
  • class Car attributes make
    String registrationNr String speed
    Integer owner Personmethods start() stop(
    ) drive(speed Integer)

5
Classes An interpretation
What are you?
What do you know?
Concept
What can you do?
Who do you know?
6
Some object oriented concepts
  • Objects, classes.
  • Attributes.
  • Operations.
  • Associations.
  • Generalisation, inheritance.
  • Message passing.

7
Message passing
  • Procedural paradigm Operations are performed by
    calling functions.
  • E.g. printPage(Book, 1), print(book).
  • Object oriented paradigm Perform operation
    passing messages to object. A class has a method
    to perform the requested action when receiving a
    message.
  • An object knows how to perform its methods on
    itself.
  • Common notation Result Object.Message.
  • Message is passed to Object, which responds by
    returning Result.

8
Java example
  • Class Library
  • printFirstPage(isbn String)
  • Book aBook
  • Page aPage
  • aBook getBook(isbn)
  • aPage aBook.page(1)
  • aPage.print()

Message to itself
Message to aBook
Message to aPage
9
What is UML?
  • UML Unified Modelling Language.
  • Notation for visual object oriented modelling of
    systems
  • Not necessarily software systems!
  • Visual 'blueprint' of system.
  • Medium for communication between people
  • Domain experts (users) and software developers.
  • Development team.
  • Usable in all stages of software development
  • Use same diagram types for different purposes.
  • Allow increase level of detail during development.

10
UML history
  • Until 1994 Many different competing methods for
    object oriented modelling and system development.
    The methods had different notations, different
    focus and different but similar concepts. gt
    Confusion, methods war.
  • 1994 Grady Booch and James Rumbaugh (Rational
    Software Corporation) started developing a
    Unified Method to unite their methods Booch and
    OMT.
  • 1995 Ivar Jacobson joined Rational, adding
    elements from his method OOSE - in particular
    Use-Case.
  • 1997 Version 1.0 of UML approved for
    standardisation by Object Management Group (OMG).

11
UML information sources
  • Books
  • http//www.amazon.com/ - search with keyword
    UML
  • M. Fowler UML Distilled, Addison-Wesley,
    2002- Short introduction to UML - excellent
  • C. Larman Applying UML and patterns,
    Prentice-Hall 1998- Explaining UML through an
    iterative development process.
  • http//www.cetus-links.org

12
UML diagrams
  • Use-case diagram
  • Class diagram
  • Package diagram
  • Sequence diagram
  • Collaboration diagram
  • State diagram
  • Activity diagram
  • Component diagram
  • Deployment diagram

13
Use-case diagram
  • A use-case diagram captures user requirements.
  • Focus on what a system should do, seen from the
    outside.
  • Model elements
  • Actor Someone or something interacting with the
    system.
  • Use-case A complete functionality, as seen from
    an actor.
  • Actors model external environment, use-cases
    model internal actions and responsibilities.

14
Use-case description
  • A use-case must be described in text.
  • Purpose Understand and document the use-case.
  • Example
  • Use-case Buy goods
  • Actors Customer, Cashier
  • Type Primary
  • Description A Customer arrives at a checkout
    with items to purchase. The Cashier records
    the items and presents the sum. The Customer
    pays the bill, takes the goods and leaves the
    shop.

15
More detailed use-case description
  • use-case Buy goods
  • Actors Customer, Cashier
  • Type Primary
  • Description
  • Actor action System response
  • 1. A Customer arrives with items.
  • 2. The Cashier records each item.
  • 3. Determine the item price and add the
    item information to the transaction.
  • 4. When all items are recorded, the Cashier
    indicates finished.
  • 5. Calculate and present the sale total.
  • 6. The Customer pays the bill.
  • 7. Register payment, and print receipt.
  • If cash see section Cash Payment
    If card see section Card Payment
  • If cheque ...
  • 8. The Customer leaves with items.


16
Sequence diagrams
  • A sequence diagram illustrates how objects
    interact by passing messages.
  • Focus on time aspects of interaction.
  • Model elements
  • Objects represent actors, whole system or class
    instances.
  • Messages sent between objects.
  • Guards define conditions for messages to be
    sent.
  • Lifeline shows explicit order of messages over
    time.
  • Activation shows how long an object is active.
  • Transition instance showing the time a message is
    sent.
  • Transition time constraining how long a
    transition can take.

17
Sequence diagram, example 1
Time
18
Sequence diagram, example 2
System
Guard
Message
Activation
Return
19
Class diagram
  • A class diagram models
  • Concepts (things) and relationships in the
    application domain
  • Classes in the implementation , e.g Java classes
  • Model elements
  • Object, Class
  • Attribute
  • Operation (Method)
  • Association, aggregation
  • Generalisation
  • Constraint
  • Package

20
Class diagram domain model
21
Generalisation (1)
  • Generalisation - one class (the sub-class) is a
    more specific variant of another class (the
    super-class).
  • Expresses the is-a-kind-of relationship
  • E.g. Cheque is-a-kind-of Payment

Generalisation relationship
22
Generalisation (2)
Multiple classification
incomplete, overlapping
complete, disjoint
sex
occupation
Multiple inheritance
23
Generalisation in a Venn diagram
  • A Venn diagram can illustrate sub- and
    superclasses

A
24
Example model
25
Packages
  • Package - organising elements into useful groups.
  • Each class belongs to exactly one package.
  • Can use a class from another package
  • Dependency between packages - a package uses
    classes from another package
  • Useful for managing complexity, organising the
    model into smaller parts, possibly
    hierarchically
  • Packages contain classes.
  • Packages contain packages.

26
Package (1)
Package
Classes in the package
Dependency
27
Package (2)
Shops
28
Package (3)
Class imported from package Shops
Products
29
Package (4)
Sales
30
State diagrams
  • A state diagram describes the state of an object,
    and change of state due to received stimuli.
  • Focus on life cycle of an object.
  • Model elements
  • State representing a situation during the life of
    an object.
  • State variables
  • Internal state activities
  • Transition representing a change from one state
    to another
  • Event specifying events leading to a transition
  • Guard specifying a condition for when a
    transition can happen
  • Action specifying actions involved in a
    transition
  • UML syntax Event Guard / Action

31
State diagram (1) Buy Goods
  • State diagram for till in use-case Buy Goods

Event
Action
Start state
State
Transition
32
State diagram (2) Buy Goods
  • Detailed state diagram for till in use-case Buy
    Goods

Event
Guard
33
State diagram (3) Digital watch
34
Activity diagrams
  • An activity diagram describes the activities
    involved in an operation or a use-case. Variant
    of a state diagram.
  • Focus on the work that is performed.
  • Model elements
  • Activity is a task is part of the activity.
  • Decision point is where a choice is made.
  • Transition defines the sequence of activities.
  • Guard describes a condition for when a transition
    can happen.
  • Concurrency bar defines concurrent activities
  • Split bar indicates activities that can happen
    concurrently.
  • Unite bar indicates co-ordination of concurrent
    activities.
  • Swim lanes assigning responsibility for
    performing activities.

35
Activity diagram (1)
  • Based on figure 9-2 from UML Distilled.

Reorder Item
Iteration
not in stock
Unite bar (Synchronise)
Outstanding Order
Decision
Check OrderItem

Assign to Order
in stock
Receive Order
Dispatch Order
Authorise Payment
succeed
Split bar (Parallel)
Transition
failed
Cancel Order
Guard
Activity
36
Activity diagram with swim lanes
  • Based on figure 9-5 from UML Distilled.

Reorder Item
not in stock
Order Processing
Decision
Outstanding Order
Swim lanes
in stock

Check OrderItem
Assign to Order
Dispatch Order
Receive Order
Cancel Order
succeed
Authorise Payment
Finance
failed
37
Component diagrams
  • A component diagram describes software components
    and their dependencies to each other.
  • Focus on assigning logical functionality to
    software components.
  • Model elements
  • Components represent software components.
  • Types of components, e.g.
  • Compile time Source, binary, executable.
  • Runtime Executable, DLL.
  • Web html, applet, documentation, image.
  • Dependencies show how one component uses other
    components.
  • One component using classes from another
    component.
  • Compilation dependencies.

38
Component diagram 1
Component
Component type
Dependency
39
Component diagram (2)
40
Deployment diagrams
  • A deployment diagram shows the run-time
    architecture of processing elements and objects
    living on them.
  • Focus on physical architecture.
  • Model elements
  • Nodes representing computational (hardware)
    resources.
  • Can be either type (class) or instance (object).
  • E.g. processors, printers, routers.
  • Connections between nodes.
  • E.g. TCP/IP, DecNet.
  • Components representing software running on a
    node.

41
Deployment diagram
42
Development process (1)
  • UML is a modelling language, not a process. But
    it should be used within some process framework.
  • A development process defines
  • what to do (tasks),
  • how to do it (tools),
  • when to do it (task order),
  • why it should be done (motivation),
  • what should be the result (products).

43
Development process (2)
44
Requirements
  • Focus
  • View system from outside / user point of view.
  • Domain (business) data and processes.
  • Non-technological.
  • Activities
  • Discussions with customer.
  • Understand requirements of system.
  • Products
  • Business terms (dictionary).
  • Business processes.
  • UML diagrams Use-case / simple class / simple
    activity.

45
Analysis
  • Focus
  • Domain data (business) and processes.
  • Non-technological.
  • Activities
  • Discussions with customers / users.
  • Understand problem domain data and processes in
    detail.
  • Describe terms / classes / association /
    behaviour in detail.
  • Products
  • Detailed but ideal conceptual model.
  • UML diagrams Use case / class / sequence / state
    / activity

46
Design
  • Focus
  • Implementing system on a computer.
  • Technological.
  • Activities
  • Divide into functional packages / layers
    (architecture).
  • Extend analysis model with implementation
    details
  • user interface, storage, communication, methods
    etc.
  • Products
  • System architecture.
  • UML diagrams Class / behaviour / component /
    deployment.

47
Implementation
  • Focus
  • Programming.
  • Activities
  • Write program code based on system design.
  • Products
  • Programs.
  • Program documentation.
  • UML diagrams Class / package / component /
    deployment

48
Discovering the model - CRC cards
  • CRC cards is a simple method for
  • learning object oriented thinking,
  • identifying an object oriented model of an
    application domain.
  • CRC Class, Responsibility, Collaboration
  • Developed in late 80s by K. Beck and W.
    Cunningham.
  • Uses index cards to capture...
  • a class,
  • its responsibilities - what the class knows and
    does,
  • classes it needs to contact to perform its
    responsibilities - collaborations
  • Encourages small classes with few
    responsibilities.

49
CRC cards Example
Class
Sale
Responsibility
Record items
Sale Item
Find total amount
Sale Item
Register payment
Payment
Sales Item
Date
Record product
Product
Description
Product Spec.
Quantity
Collaborations
50
Mapping to Java Example (1)
51
Mapping to Java Example (2)
  • public class Sale / Attributes /private
    Boolean isCompletepublic Date date/ Methods
    /public Boolean makeComplete()public void
    makePayment()public Double total()/
    Associations /public SalesItemVector
    itemspublic Payment thePayment
  • public class SalesItempublic Integer
    quantitypublic Product theProductpublic
    ProductSpec description
  • public class Payment public Double amount
  • public class Cash extends Payment

52
Code generation from UML
  • UML can be mapped automatically to a programming
    language implementing the modelled structures.
  • CASE tools can generate code from an UML model.
    Mapping can be into
  • Programming languages C, Java, ...
  • Visual programming toolsVisual Basic, Delphi,
    ...
  • RDBMS Oracle8, SQL DDL, ...
  • OODBMS O2, ObjectStore, Objectivity, POET, ...
  • Middle ware Persistence, Rogue Wave, Corba IDL,
    ...

53
Reverse Engineering to UML
  • In many cases an implementation can be reverse
    engineered into a UML model.
  • Round Trip Engineering
  • Rational Rose can reverse engineer from several
    sources
  • Programming language Java, C
  • RDBMS Oracle8

UML modelling
Reverse Engineering Java to UML
Mapping UML to Java
54
Summary
  • We have discussed most of UMLs modelling
    elements
  • User requirements
  • Use-case diagram, activity diagram.
  • Static aspects
  • Class diagram, Package diagram.
  • Dynamic aspects
  • Sequence diagram, Activity diagram, State
    diagram.
  • Mapping to implementation platform
  • Relational database.
  • OO programming language, e.g. Java.

55
How to make good UML models
  • Practice!
  • Practice!!
  • Practice!!!
  • Stick to the KISS principle
  • Keep It Simple, Stupid!

56
UML is not a silver bullet
  • Usual mode of software development is still
    often...
Write a Comment
User Comments (0)
About PowerShow.com