280 likes | 493 Views
Introduction to the Unified Modelling Language Pauline A. Wilcox Department of Computer Science. Aims. This lecture introduces the UML: Will discuss, what it is … and what it is not Components of UML: Use Case Diagram Class Diagram Interaction Diagrams Activity Diagrams State Charts.
E N D
Introduction to the Unified Modelling Language Pauline A. Wilcox Department of Computer Science
Aims • This lecture introduces the UML: • Will discuss, what it is … and what it is not • Components of UML: • Use Case Diagram • Class Diagram • Interaction Diagrams • Activity Diagrams • State Charts
An Alternative View Requirements Capture System Structure System Behaviour Use Case Diagram Class Diagram Interaction Diagrams Activity Diagrams State Charts
About the UML • The Unified Modelling Language (UML) is an industry standard for object oriented design notation, supported by the Object Management Group (OMG). • It is becoming widely adopted in many areas of the software and computer systems development community. Some references included at end of lecture notes
Activity Take a couple of minutes to read through the introductory Bank case study on the following slides. Try and pull out the key things which we might want to represent in a model of the Bank as described. Focus on requirements Can also look for candidate classes and methods
Introductory Case StudyThe Bank Account You are asked to design a system to handle current and savings accounts for a bank. Accounts are assigned to one or more customers, who may make deposits or withdraw money. Each type of account earns interest on the current balance held in it. Current accounts may have negative balances (overdrafts) and then interest is deducted. Rates of interest are different for each type of account. On a savings account, there is a maximum amount that can be withdrawn in one transaction.
Introductory Case StudyThe Bank Account Bank employees may check any account that is held at their branch. They are responsible for invoking the addition of interest and for issuing statements at the correct times. A money transfer is a short lived record of an amount which has been debited from one account and has to be credited to another. A customer may create such a transfer from their account to any other. Transfers within a branch happen immediately, while those between branches take three days.
The Bank Case Study • Use Case Diagram • Examine and capture requirements • Activity Diagram • Illustrate dependencies in system • Class Diagram • Start to examine system structure • Interaction Diagrams • Express system dynamics Illustration and description in following slides
A Use Case Model • Nearly all object oriented design methods now use use case models to represent requirements. • Use case modelling was invented by Ivar Jacobsen, one of the three amigos who created UML. • A use case model shows the external view of a system which is being designed.
deposit withdraw transfer customer statement teller This is one possibility add interest A Use Case Model of the Bank
What’s in a Use Case? • A use case model can be shown as a use case diagram • Such a diagram shows: • actors • the roles adopted by those participating • use cases • high level activities to be supported by the system • links • which actors are involved in which use cases
Dependencies between Use Cases • Customers who want to open a new account, must check with the manager • The manager also has to check the books from time to time • Clearly the request for a new account depends on whether the manager is available to act in his role of authorising the customer’s request • Can show dependencies via Activity Diagram
Not on Use Case diagram? Open New Account Activity Diagram Done [no accounts to do] Free Enter [accounts to do] Ready Doing Accounts Request Authorisation Complete Wait Teller Manager Customer
Customer 1 withdraws and deposits money with 1 withdraws and deposits money with 0..* Current account 1 0..* 1 Branch holds holds 0..* 0..* Transfer Savings account moves money to moves money to 1 1 1 1 1 1 summarises Statement summarises 1 1 A Class Diagram of the Bank -balance : real +withdraw(a:Real) +deposit(a:Real) +curBal():Real
Example showing Specialisation Customer 1 0..* Account 1 0..* holds Branch moves money to 1 1 Transfer Current Account 1 Savings Account summarises Statement 1
Showing Interactions • The Use Case Diagram captures requirements • The Class diagram shows static structure • Important to show how objects of this type interact to satisfy the requirements • A Choice of Two Diagrams in the UML: • Sequence Diagram • Collaboration Diagram
c:Customer ac1:Account b:Branch :ACustomer :Teller deposit(v,a,name) c:= getRec(name) ac1 := getAcc(a,c) addToBalance(v) Sequence for a successful deposit
Collaboration Diagram b:Branch c1:Customer :ACustomer :Teller This open diamond notation is an aggregate association ac1:Account
Collaboration Diagram b:Branch 1.1:c:= getRec(name) 1:deposit(v,a,name) 1.2:ac1 := getAcc(a,c) c1:Customer :ACustomer :Teller 1.3addToBalance(v) ac1:Account
And Finally ... … to complete our whirlwind tour of UML we look at state charts Moves away from the introductory Bank case study
Internal Behaviour - Statecharts • How do we show how objects behave? • One way is to give the code for the methods (functions) which support each operation. • Much behaviour depends on the state of the object, i.e. the values of its attributes and, possibly, of the attributes of its collaborators. • The current state of an object can be shown in a statechart (We use a different example for this) • All objects of the same class (not just the same interface) have the same statechart.
Activity • Take a brief while to consider what the following statechart represents …
Example State Chart move( r,c)/^ umpire.validate(‘ X’,r,c) XtoMove XtoMove XtoMove XhasMoved invalid()/^ xPlayer.makeAMove() valid()/^ xPlayer.makeAMove() valid()/^ yPlayer.makeAMove() Y’,r,c) move( r,c)/^ umpire.validate(‘ YhasMoved YtoMove invalid()/^ yPlayer.makeAMove()
A Few Example Class Diagrams • The examples on the following slides relate to coursework 1 for this module • That does not mean there are any ‘answers’ here, but it may give you something to think about!
Post Lecture Activities • Lots of other resources for UML General Object Management Group http://www.omg.com/ The UML Zone http://www.uml-zone.com/ Tools/Methodologies UML Open Edition http://www.umlopenedition.com/ argoUML http://argouml.tigris.org/ Rational http://www.rational.com/ <-- also lots of white papers available Catalysis http://www.trireme.u-net.com/catalysis/ The New Methodology http://www.martinfowler.com/articles/newMethodology.html Books Perdita Stevens and Rob Pooley, Using UML - Software Engineering with Objects and Components Addison Wesley ISBN 0-201-64860-1 • Comprehensive UML notes also available from http://www.macs.hw.ac.uk/~paw/teaching/dsa1/uml/