uml and wsdl for jisc e-learning projects introduction to uml richard hopkins [email protected] nesc...
TRANSCRIPT
UML and WSDL for JISC e-Learning Projects
INTRODUCTION TO UML
Richard Hopkins [email protected]
NeSC Training Team Member
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 2
Goals and Overview
Goals –To enable you to understand the UML part of the first example To explain the context and overall approach for UML
OverviewUML History and conceptsSimple use of most essential diagrams
Requirements Structure Behaviour
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 3
History of UML
Use of diagramsIn any discipline for the construction of complex artefactsNeed to use diagrams, as tools for
Thinking Communicating
As discipline matures, diagrams become - Standardised – For effective communication between all practitioners Stylized – Specialised technical language for compact representation
UML – M is for ModelsA diagram is a model of the (proposed) systemA partial representation of some aspect of the system
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 4
History of UML
Historically A variety of stylised diagram languagesEach associated with a design methodology
A formalised Process for arriving at a design
E.g., for Object-oriented design (early 90’s) Grady Booch’s OOD – Object-Oriented Design James Rumbaugh’s OMT – Object-oriented Modelling and Design Ivar Jacobson’s OOSE – Object-Oriented Software Engineering
Competing MethodologiesRather improbably –
Rumbaugh joined Booch, with intention of merging their methods
They bought out Jacobsonn’s company – Objectory These three aimed for a single Unified Method
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 5
Methodolgy vs Notation
Generally need different methodologies for different contexts
Small application in four weeks by single programmerLarge system in four years by 200-strong development organisation
Often “use of X methodology” was actuallyuse of “X’s”notation with methodology appropriate to context
Strong reasons for using the same notation
Concept of Unified Method, changed to Unified Modelling Language
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 6
Methodology vs Notation
UML is NOT a methodologyUML is a notation for recording the results of
A requirements gathering / design processCarried out using some methodology – maybe!
Any kind of diagram can be used for any purpose that is useful
Sufficiently general that could be used with any imaginable O-O methodology
However, for concreteness we will assume a particular general methodology -
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 7
An Overall Development Process
Partially articulated requirements
Capture Requirements
Use Case Diag. Requirements
ConstructModel of
Overall system Class Diag. Structure
Sequence Diag. Behaviour
These diagram types, and the process can be used both forDesigning a new systemUnderstanding an existing system
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 8
Requirements
OverviewUML History and conceptsSimple use of most essential diagrams
Requirements Structure Behaviour
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 9
Introducing the Library Example
A computer system for a university library; some “facts”
The library has members –StaffStudents
The library contains items -Books
possibly several copies of each book Some books are for short-term loan only – only students can do short-term loans
Journals Only staff may borrow journals
The functionalities includeKeeping track of when items are borrowed/returnedAllow users to search for a book and check availability
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 10
Some Queries
The library has members –StaffStudents
The library containsBooks;
possibly several copies of each book Some books are for short-term loan only – only students can do short-
term loans
Journal Only staff may borrow journals
The functionalities includeKeeping track of when items are borrowed/returnedAllow users to search for a book and check availability
Can someone be both?
Do we mean copies?
Is “user” something different from “member?Henceforth use “user”
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 11
Requirements Engineering
Natural language statement of requirements is typically riddled with ambiguities and inconsistencies
Requirements Engineering is the discipline of dealing with this
Developing UML models helps with identifying and clarifying requirements
But still depends on natural language documentation
It helps, but does not guarantee complete consistent set of requirements
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 12
Requirements - Simple Use Cases
An Actor –a user of the system, in a particular role
“BookBorrower” is a role played by library membersUsually a person, but could be another system
An entity outside the system being modelledIn web services – usually another web service
BookBorrower
Borrow Copy of book
UpdateCatalogue
Librarian
A Use Case –A task that an actor needs to perform with the help of the system“Borrow Copy of Book” describes the successful outcome – there will be variants for the exception cases -
This Actor participates in this Use Case
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 13
Simple Use Cases
Not a very rich diagram – later on we will see richer diagramsNeeds more explanation – associated documentation
Limitations of natural language!
BookBorrower
Borrow Copy of book
Use Case Documentation
Use Case: Borrow copy of book.
• A bookBorrower presents a book.
• The system checks that the potential borrower is a member of the library,
• and that s/he does not already have the maximum permitted number of books on loan.
• The maximum is 6 unless the member is is a staff member, in which case it is 12.
• If both ckecks succeed, the system records that this library member has this copy of the book on loan.
• Otherwise it refuses the loan.
UpdateCatalogue
Librarian
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 14
STRUCTURE
OverviewUML History and conceptsSimple use of most essential diagrams
Requirements Structure Behaviour
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 15
Structure - Class Design
UML is for Object-Oriented DesignThe state of the system is a collection of ObjectsEach Object is an instance of a ClassThe structure of the system is characterised by the class and their inter-relationships
Key is identifying the classeskinds of things manipulated within the system
Standard Technique - Noun identification
Take a concise description of the systemIdentify the words/phrases that denote things
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 16
Noun Identification
Some Facts –
The library contains books and journals.
It may have several copies of a given book.
The system must keep track of when items are borrowed and returned
The system must allow users to borrow items subject to rules –
A student can borrow up to six items …
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 17
Class Design – Which Nouns?Library
Book
Journal
Item
System
Rule
User
Student
☺
NO – Not “within the system”
Yes if rules are updatable
No if rules are built in
Yes – All these are things which the system needs to trackAlthough they are not independent – Journal is a special case of item Student is a special case of user
Here a “book”, “student” etc. within the system – Represents an actual entity in the external world Partially Tracks what is happening to the real world entity
☺
☺
☺
☺
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 18
Class Diagram
A box for each ClassThere are relationships between classes
Otherwise don’t need a diagram!!!
User
Student Staff
Item
Journal Book
Specialisation/GeneralisationUser is a generalisation of both
Student Staff
Any instance of Student is also an instance of User
Student
Later we will see other class relationships
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 19
Class Attributes and Operations
Book
Title : String
Item
Journal
Attribute – Information associated with each instance of the class –
what’s important for understanding; not all that exists in a programming language class implementing it
Each attribute will have a type
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 20
Class Attributes and Operations
Book
Title : String
copiesOnShelf() : Integer
Item
Journal
An operation – something that instances of this class can do, which can be externally invoked
A unit of functionality which is externally exposedEquivalent to a Java Method
copiesOnShelf() : IntegerTo provide the invoker with a number which is the number of copies of the book which are available for borrowing.
copies(in onShelf:Bool, out copyNos[0..*] Integer) : Status
UML terminology is message-passing - An object’s operation is invoked by another object sending it a message
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 21
Web Services as Objects
A WSDL definition corresponds to a class “a service type”
An actual web service conforming to that definition is an instance of that classBut service types are often not found by “noun identification”
Often more byIdentifying Functions, rather than things
Legacy Overall domain understanding (guesswork / intuition) Notion of layered architecture
Viewing a function-provider as a service object
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 22
Example some Web ServicesA Web services Framework for E-learning (surprise!)
User Agents (layer)
Portal Timetabling Library Authoring Tool . . .
Application Service (layer)
Group Management Resource Discovery Resource Management . . .
Common Services (layer)
. . .Authentication Authorisation Search Messaging
Naturally a domain noun? –YesNo
(As perceived by domain non-expert!)
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 23
BEHAVIOUR
OverviewUML History and conceptsSimple use of most essential diagrams
Requirements Structure Behaviour
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 24
Behaviour - Sequence Diagrams
To Document how objects work together to achieve an overall function of the system –
An Interaction Diagram
Each sequence diagram shows an example “walk-through”
Typically for a use case
Not for all of themFor
Complex situations Where clarification seems needed
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 25
Sequence Diagram - participants
For Use Case : Borrow copy of book
BookBorrower
theUser: User theCopy: Copy theBook: Book
Identify the participantsExternal Actor from the use caseObjects within the system
This is an instance diagram –
Name each object, and identify its classtheUser – object which is the internal representation of the user playing the BookBorrower role“theUser : User” seems redundant, but could have several User participants
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 26
Sequence Diagram – LifelinesBookBorrower
theUser: User theCopy: Copy theBook: Book
time
Object existence lifeline Period of activation
1:
3:2:
4:
1. BookBorrower invokes the use case – activating the corresponding User object, theUser
2. theUser tells theCopy object that it is now borrowed – it changes its state3. theCopy tells theBook that it has been borrowed – its reduces its count of
available copies4. TheUser confirms success to BookBorrower
The replies to 2 and 3 not shown because not particularly important, whereas the confirmation to external user is.
Sending a message
The reply
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 27
Sequence Diagram – Operations
BookBorrower
theUser: User theCopy: Copy theBook: Book
time
Object existence lifeline Period of activation
1: borrow(theCopy)
3: borrowed()2: borrow()
4: borrowStatus
Associate with the message line –The information communicatedUsually the operation invoked and possibly its parameters
Sending a message
The reply
JISC UML/WSDL – Introduction to UML, 9th Nov. 2004 28
Final PointsUML is a language to enable expression
Its up to you what you express and what you don’t
Which cases you give sequence diagramsWhich attributes you include for a class. . .
Based on maximising usefulness to the reader
Rather than rigid rules
Butit maybe you organisation’s standards, rather than your personal judgement