Presentation is loading. Please wait.

Presentation is loading. Please wait.

Unified Modeling Language

Similar presentations


Presentation on theme: "Unified Modeling Language"— Presentation transcript:

1 Unified Modeling Language
Chapter 4 Squeak: Object-oriented design with multimedia applications

2 Unified Modeling Language
There have been O-O gurus for many years Three of them worked together to define UML (“Three amigos”: Booch, Rumbaugh, Jacobson) Has now been approved as a standard by the Object Management Group (OMG) UML is a notation/language not a process Diagrams and notation from UML 1.4 definition; 1.5 is the latest; see:

3 Diagrams Class diagrams: Represents static structure
Use case diagrams: Sequence of actions a system performs to yield an observable result to an actor Sequence diagrams: Shows how groups of objects interact in some behavior State diagrams: Describes behavior of system by describing states of an object Plus others

4 UML Class Diagrams Classes are boxes Lines are relationships
Top is name Middle are attributes Bottom is services Lines are relationships Arrows show navigability

5 How can two classes be related?
Generalization-specialization or IsA NamedBox IsA Box Diagram: Triangle on the relationship line Association or HasA Box HasA Pen Diagram: Just a relationship line Aggregation is a part-whole relationship, but not exclusive Diagram: Open diamond on the line Composition is a part-whole relationship that is exclusive Diagram: Closed diamond on the line Dependency or TalksTo Dependency is sort of temporary HasA Diagram: Dashed line in UML

6 The Aggregation-Association Issue
It’s not clear when, in UML, you notate that one thing “has” another. Coad: “An example of aggregation is the relationship between an organization and its clerks” Rumbaugh: “A company is not an aggregation of its employees” How many OO experts does it take… Safest: Use an association unless the definition of “aggregation” is clear to your audience

7 More on UML Class Diagrams
Navigability Both ways or just one? Who knows about the other? Does the Box have the Pen or the Pen have the Box? Usually added later in the process Book is wrong on bidirectional (no arrows is bidirectional, not double arrows.) Multiplicities How many Pens per how many Boxes? Can add labels to indicate how reference is viewed

8 Concrete and Abstract Classes
Concrete classes are those that we create instances from Abstract classes are never instantiated They exist to define structure and behavior for other classes to inherit In UML, abstract classes use italics when naming the class, or <<abstract>> keyword

9 Use Case Diagrams Means of capturing requirements
Document interactions between user(s) and the system User (actor) is not part of the system itself But an actor can be another system An individual use case represents a task to be done with support from the system (thus it is a ‘coherent unit of functionality’)

10 Simple Use Case Diagram
Reserve book Borrow book Return book

11 Use Case Diagram with Multiple Actors

12 Use Cases Are actually defined as text, including descriptions of all of the normal and exception behavior expected Do not reveal the structure of the system (i.e. the system does…) Collectively define the boundaries of the system to be implemented Provide the basis for defining development iterations Use language of user

13 Use Case Descriptions USE CASE UC1: Process Sale
Primary Actor: Cashier Stakeholders and Interests: - Cashier: Wants accurate, fast entry, no payment errors - Salesperson: Wants commissions updated - Customer: Wants purchase and fast service. Wants proof Preconditions: Cashier is identified and authenticated Postconditions: Sale is saved. Tax correctly calculated. Accounting and inventory are updated. Commissions recorded. Receipt is generated. Payment authorizations are recorded. Main Success Scenario: 1. Customer arrives at POS checkout with goods/services to buy 2. Cashier starts a new sale. 3. Cashier enters item identifier. 4. System records sale item and presents item description, price, and running total. Price calculated from a set of price rules.

14 Use Case Descriptions Cashier repeats steps 3-4 until indicates done
5. System presents total with taxes calculated. Extensions / Exceptions: *a. At any time, System fails: To support recovery and correct accounting, ensure all transaction sensitive state and events can be recovered from any step of the scenario. 1. Cashier restarts System, logs in, and requests recovery of prior State : Restart System. 2. System reconstructs prior state. 3a. Invalid Identifier: 1. System signals error and rejects entry. Special Requirements: - Touch screen UI on large flat panel monitor, Text visible from 1 meter - Credit authorization response within 30 seconds, 90% of time. Frequency of Occurrence: May be continuous Open Issues: Explore recovery state, Tax Law variations?

15 Sequence (Event) Diagrams
Shows individual objects and how they interact Describes Lifelines of objects Who sends what messages when Can also describe sending messages to self ("self-delegation")

16 Example Real Time Sequence Diagram

17 State Diagrams Describe all the possible states a particular object can get into, and the events that lead to those changes Also called a "statechart"

18 Example State Diagram

19 UML in Real Practice You don't typically use all the diagrams
You'll choose between them based on preference and particular situation You typically use many diagrams A single use case may not capture all scenarios If you are going to use statecharts, there are probably lots of objects with states Each sequence diagram only shows one interaction

20 Example: Student Registration System
Not going to do all the diagrams Not all types, not even all that completely specify the system But this is an application you know, so the examples may help make sense

21 Student Registration Class Diagram (Early Analysis Level)
Transcript gradeForCourse: takenCourse: Student 1 1 historyRecordedIn * getsScheduleFrom 1 Registrar getSectionsFor: enrollInSection: dropFromSection: Section assigns * * 1 enrollInClass: daysAndTime gradeInCourse: roster takenCourse: * 1 addStudent removeStudent * 1 * majorsIn * * * CourseGrade taughtIn manages 1 Department requiredCourses 1 * givenFor grade Course name number creditHours 1..3 * termEnrolled * * * * prereqs 0..3 owns hasPrereqs 0..3 0..3 0..3 prereqs

22 Partial Use Case Diagram
Apply for Admission Admissions Enroll in the University Student Enroll in a Course Withdraw from a Course

23 States of a Student Enrolled Registered
Apply [ Must be accepted first ] Enrolled EnrollInClass ( Add a Transcript ) Registered Withdraw AddCourse Graduate [ All courses must be completed ]

24 Sequence Diagram: Registering for Course
aStudent: Student theRegistrar : Registrar aSection : Section theTranscript : Transcript getSectionsFor: return sections enrollInSection: takenCourse: prerequisite state of prereq [havePrereq] addStudent: enrolled enrolled

25 UML Tools Most complete tool: Rational Rose, http://www.rational.com
Lots of others Together by Object International BOOST (Basic Object-Oriented Support Tool) by Noel Rappin, available on CD/CoWeb Argo-UML, ObjectPlant, Posiden, etc. diagramming tools, e.g. Visio, xfig

26 For More Information… Serious O-O designers do use UML
UML Distilled by Martin Fowler is a good practical introduction to UML Official UML book series published by Addison-Wesley UML Resource Center


Download ppt "Unified Modeling Language"

Similar presentations


Ads by Google