UML Use Cases using Magicdraw

UML Use Cases using Magicdraw Robin Beaumont [email protected] Tuesday, 04 October 2011 Contents 1 Required Resources ..........................
Author: Milton Parks
15 downloads 1 Views 1MB Size
UML Use Cases using Magicdraw Robin Beaumont [email protected] Tuesday, 04 October 2011

Contents 1

Required Resources ............................................................................................................................................... 2

2

Revision ................................................................................................................................................................. 2

3

Our problem .......................................................................................................................................................... 2

4

Setting the perspective you will use in MagicDraw ................................................................................................. 3

5

Creating a new project ........................................................................................................................................... 4

6

Creating a new Diagram ......................................................................................................................................... 5

7

The project window and diagram toolbar - moving around and Zooming................................................................ 6

8

Removing the grid on the drawing canvas .............................................................................................................. 7

9

Creating an Actor ................................................................................................................................................... 7

10

Creating individual use cases and associations .................................................................................................... 8

11

Tidying the lines ................................................................................................................................................. 9

12

Adding notes ...................................................................................................................................................... 9

13

Saving your project and diagram .......................................................................................................................10

14

Displaying diagram information ........................................................................................................................10

15

Include, Extend and Inheritance ........................................................................................................................11

16

Finding out properties .......................................................................................................................................11

17

Learning more about Use Case diagrams ...........................................................................................................12

18

A common interface ..........................................................................................................................................12

Using MagicDraw to Create UML Use Case diagrams

1 Required Resources You need the following resources to work through this document: The “Scenarios for practicing modelling techniques” handout available from http://www.robin-beaumont.co.uk/virtualclassroom/case_tutorials.htm MagicDraw software, this depends on who you are: Students at The Royal College of Surgeons (Edin.) will be provided with the software along with the academic licence. All others can obtain the software by visiting and registering at: http://www.magicdraw.com/ for the free community edition. An alternative with a similar interface is Visual Paradigm (VP-UML). The purpose of this practical chapter is to provide you with the skills to draw Use Case diagrams in Magicdraw. Other documents explain what Use case diagrams are and where they fit into the modelling process.

2 Revision You should possess knowledge of what Use case diagrams are before working through this practical chapter. You should have preferably worked through the document; Dynamic modelling and UML part 12 - Use cases and sequence diagrams at: www.robin-beaumont.co.uk/virtualclassroom/chap11/s3/use_case_sequence_uml.pdf Alternatively An excellent introduction, along with a general introduction to UML, can be found at: http://www.developer.com/design/article.php/10925_2109801_1 Also a good book chapter on Use Cases can be found at; http://www.visual-paradigm.com/special/requestootsamplechapters.jsp

3 Our problem In this practical chapter we are going to produce a UML Use Case diagram from a narrative description. I assume you have worked through the material explaining what a Use Case diagram is and how you derive the required information from a narrative description. To find out about the descriptions open the document ''Scenarios for practicing modelling techniques” from http://www.robin-beaumont.co.uk/virtualclassroom/contents.html and read through the Local Community Radio Station narrative. My tentative list of Actors and Use cases from the narrative are: Processes

Actor Hospitals

Roles

Schools Manager

Use Case Create item Create programme

Administrator

Present Programme

Recording engineer

Maintain feedback log

Editor

Monitor

Presenter

Book studio

Secretary

Maintain equipment

Volunteer

Now let's see how we use the above information to create a UML Use Case diagram in MagicDraw. If you have used MagicDraw before you can move to section 5.

Robin Beaumont [email protected] D:\web_sites_mine\HIcourseweb new\chap11\case_tool_tuts\magicdraw\use_case_2007.docx

Page 2 of 12

Using MagicDraw to Create UML Use Case diagrams

4 Setting the perspective you will use in MagicDraw The first time you open MagicDraw after installing it you are asked to specify what type of user you are ('user perspective'). Set the options as shown in the screen shot below.

The first screen is rather cluttered, to say the least, so the first thing I suggest you do is close the Welcome window

Although the screen appears very complex you can think of it as consisting of 4 main areas: Menu Toolbars Browser window Drawing Canvas

Robin Beaumont [email protected] D:\web_sites_mine\HIcourseweb new\chap11\case_tool_tuts\magicdraw\use_case_2007.docx

Page 3 of 12

Using MagicDraw to Create UML Use Case diagrams

5 Creating a new project We are now ready to create a new project which will include our Use case diagram. To do this click on the menu option File -> new project. Selecting this menu option brings up a dialogue box asking a name for the project and a place to save it. The screen shot below tells you which options to choose in each dialogue box.

Robin Beaumont [email protected] D:\web_sites_mine\HIcourseweb new\chap11\case_tool_tuts\magicdraw\use_case_2007.docx

Page 4 of 12

Using MagicDraw to Create UML Use Case diagrams

6 Creating a new Diagram We now have a relatively empty screen, let's review some interesting aspects of it before moving on. Along the toolbar at the top of the screen there are a series of icons which allow you to easily create new UML diagrams of various types. Along the left hand side of the screen there is a panel with four tabs along the top of it clicking on the third one 'diagrams' provides us with a graphical display of the diagrams we might have in the project, as we would expect this is empty at the moment. Finally notice that the middle of the tool bar provides you with details of the actual project filename 'radio station.mdzip' along with where it is on the hard drive.

Besides clicking on the appropriate icon on the toolbar to create a new diagram is it possible to do it the old fashioned way by using the menu option Diagrams -> Use Case Diagrams. Once you choose this the Use case diagrams dialogue box appears which is empty at the moment, click the 'Add' button and follow the instructions in the screen shot below.

Robin Beaumont [email protected] D:\web_sites_mine\HIcourseweb new\chap11\case_tool_tuts\magicdraw\use_case_2007.docx

Page 5 of 12

Using MagicDraw to Create UML Use Case diagrams

7 The project window and diagram toolbar - moving around and Zooming

Robin Beaumont [email protected] D:\web_sites_mine\HIcourseweb new\chap11\case_tool_tuts\magicdraw\use_case_2007.docx

Page 6 of 12

Using MagicDraw to Create UML Use Case diagrams

8 Removing the grid on the drawing canvas One thing I find annoying is the grid on the drawing canvas, follow the details below to remove it.

9 Creating an Actor The panel on the immediate left of the drawing canvas provides a easy way of creating various UML elements onto the drawing canvas by dragging them across.

Exercise 1: Follow the instructions above to create the project Radio Station and a UML use case diagram called Overview.

Robin Beaumont [email protected] D:\web_sites_mine\HIcourseweb new\chap11\case_tool_tuts\magicdraw\use_case_2007.docx

Page 7 of 12

Using MagicDraw to Create UML Use Case diagrams Exercise 2: Add the following actors to your use case diagram:

10 Creating individual use cases and associations To create individual Use Cases you select the use case icon on the left hand panel and drag it onto the drawing canvas. To name it you just start to type immediately.

Actors in Use Case diagrams communicate with Use cases via associations. Important: the term association here does not have the same meaning as an association in UML Class diagrams I tend to think of these as messages. The diagram on the right shows you how to create an association. The pop up menu appears when the Use case is selected.

Robin Beaumont [email protected] D:\web_sites_mine\HIcourseweb new\chap11\case_tool_tuts\magicdraw\use_case_2007.docx

Page 8 of 12

Using MagicDraw to Create UML Use Case diagrams

11 Tidying the lines Once you start to add a number of associations the diagram will become to look rather messy. One easy way of tidying it up is to change the style of the lines. I would recommend that you usually keep the same line style for all the lines within a particular diagram.

12 Adding notes The Use case diagram we are creating is just an overview of the system we are beginning to model, one of the main purposes of a Use Case diagram is to encourage discussion between all the stakeholders therefore an initial diagram will contain many questions that will need clarifying in drawn out meetings.

To create a note click on the note icon and then click the drawing canvas.

Exercise 3: Modify your Use Case diagram to resemble the one below:

Robin Beaumont [email protected] D:\web_sites_mine\HIcourseweb new\chap11\case_tool_tuts\magicdraw\use_case_2007.docx

Page 9 of 12

Using MagicDraw to Create UML Use Case diagrams

13 Saving your project and diagram Always remember to save your project. This will include all the diagrams etc. If you wish to make copies with different names use the Save Project As . . option.

14 Displaying diagram information It is possible to display a table showing such things as the diagram name, author, and creation, modification dates. While in the drawing canvas right mouse click in an empty part of the diagram you want to add the information table to. A properties menu appears which you just need to click on the 'Show diagram info' option.

Once you have done this a information table will appear in the diagram.

You can move the table by clicking on it and dragging it around the diagram. You can also change its contents, look and feel by selecting it and then right clicking, selecting Customize, which brings up its own project options box. To change the text size font etc just use the menu options along the top of the drawing canvas after selecting the information table.

Robin Beaumont [email protected] D:\web_sites_mine\HIcourseweb new\chap11\case_tool_tuts\magicdraw\use_case_2007.docx

Page 10 of 12

Using MagicDraw to Create UML Use Case diagrams

15 Include, Extend and Inheritance You use the same technique as described above to add other diagram elements such as include, extend and inheritance associations. In the example below I have indicated that the process of creating a programme involves creating items.

16 Finding out properties It is easy to find out what characteristics of a particular element (e.g. actor, Use case, association etc) you can edit. You can either select the element by left mouse clicking on it then once selected RIGHT mouse click which brings up a menu. Alternatively you can constantly see the characteristics of the currently selected element by moving to the properties tab of the browser window. Rather than selecting the element you want on the actual diagram you can go to the containment tab of the browser window and select what you want there.

Robin Beaumont [email protected] D:\web_sites_mine\HIcourseweb new\chap11\case_tool_tuts\magicdraw\use_case_2007.docx

Page 11 of 12

Using MagicDraw to Create UML Use Case diagrams

17 Learning more about Use Case diagrams MagicDraw comes with two case studies, the Inventory control system and a Library system. The Inventory control system has a simple Use case diagram while the Library system contains a much more complex one. I personally feel that the Inventory control system's Use case diagram reflects the spirit of the Use case diagram more accurately. See what you think.

18 A common interface You might be interested to know that superficially the screen layout of MagicDraw is very similar to a number of other Case tools so once you have learnt it you should have little difficulty moving to several others. It is important to realise that while each Case tool may look initially very similar, in fact most offer very different features. The screen shot opposite is that of another UML case tool VP-UML.

End of document

Robin Beaumont [email protected] D:\web_sites_mine\HIcourseweb new\chap11\case_tool_tuts\magicdraw\use_case_2007.docx

Page 12 of 12