文档库 最新最全的文档下载
当前位置:文档库 › 3342_T1_BlueJ_UML_Tutorial

3342_T1_BlueJ_UML_Tutorial

3342_T1_BlueJ_UML_Tutorial
3342_T1_BlueJ_UML_Tutorial

1. Getting Started

1.1 Launching BlueJ - UML

On Windows and MacOS, extracted the downloaded zip file and run the BlueJ.exe

and BlueJ.app on Windows and MacOS correspondingly .

On Unix systems , installation is required. If you are using ubantu, installation could

be perform by double click the downloaded BlueJ-3.1.4.deb. For others, Run the installer by executing the following command:

sudo dpkg -i bluej-3.1.4.deb

After installation, run the BlueJ deb package to launch the BlueJ UML

1.2 Explore Menus

The typical menus available on the menu bar of an BlueJ - UML window are:

?Project menu

?Edit menu

?Tool menu

?View menu

?Help menu

Description

Menu

Name

Project The Project menu allows you to open project for editing, save editor content and close the opened project so as the BlueJ UML. Among the other things, it

also allows you to import existing BlueJ or BlueJ UML projects and create Jar

Files.

Edit The Edit menu allows you to perforfm new class, new package, add class from file, remove class, new uses arrow and inheritance arrow.

Tool Compliation, rebuild package, reset Vm, use librart class and show use-case tool could be done using the Tool menu.

View The View menu allows you to show dependency in class diagram, debugger, terminal and code pad.

Help The Help menu can be used to search helper tips, add BlueJ extension.

2. Working with classes and dependency

2.1 Create BlueJ –UML Project

To create a project, select New Project from the Project menu. Select the project location and enter the Project Name. Click “Create” to crete the project.

2.2 Create class

Class could be created through selecting the “new class” menu item in edit menu tab, the “New Class…” tab on the left hand side and right click on the main window.

2.3 Remove Class

Class r emoval c ould b e p erform b y r ight c lick t he c lass a nd s electing t he “Remove” m enu i tem .

2.4 Compilation

To compile a class, click the Compile button in the editor. To compile a project, click the Compile button in the project window.

2.5 Edit soure code of a selected class

Double click the class name to open a editor and edit the code directly in the text editor. Save the changes by clicking “Save” in the “Class” Menu and compile the code.

2.6 Edit class attributes and methods

Double click the attributes/methods you would like to edit. The sign character ‘+’ represents public publicity which could also be set to ‘-’, ‘#’, or ‘’, respectively, for private, protected, or package visible sharing. Amendment on the parameter type and return type could also be made. After clicking the “OK” button and compilation, code will be updated instantly.

Changes could also made through correcting the code directly. Changes will be reflected in class after compilation.

2.7 Create linkage between classes

Class linkages including association, aggregation and composition could be created between classes. Association and aggregation relationship could be form by clicking the corresponding arrow button placed on the left hand side and a simple drag-and-drop operation as display in the follow image. Compile the program and the corresponding source code will be updated.

Linkage could also created through identifying them in source code. Compile the program and the constructed linkage will be reflected in class diagram.

2.8 Remove linkage between classes

Every linkage in a class diagram could be deleted by right click on it and click on remove button. Removal of any linkage in a class diagram will also reflect in source code. The original related source code would be updated to reflect the removal operation.

Same as linkage construction, linkage removal could be done by correcting source code. Corrsponding linkage will be destroy after compliation.

2.9 Editing multiplicities for aggregation and composition

BlueJ--‐UML s hows m ultiplicity o f a ggregation a nd c omposition. M ultiplicities could b e m odified b y r ight c lick t he a ggregation/ c omposition a nd c hoose t he “Change m ultiplicites” i tem. S ource c ode w ill b e c orrected a fter c ompilation.

Multiplicites c ould a lso b e a mmened b y c hanging t he c ource c ode d irectly. Changes w ill b e r eflected o n t he c lass d iagram a fter c ompliation.

2.10 Edit role of dependency

Role o f d ependency c ould b e u pdated b y r ight c lick t he l inkage a nd s elect “Change R ole”. M odification w ill b e r eflected i n s ouce c ode a fter c ompliation.

Simliarily, u pdating r ole o f d ependency i n s ource c ode w ill a lso u pdate t he c lass diagram a fter c ompliation.

3. Working with Objects

3.1 Create object instance

A k ey c haractertics o f

B lueJ--‐UML i s t hat y ou c ould d irectly i nteract w ith s ingle class a nd e xecute t heir p ublic m ethods i nstead o f j ust e xecute a f ull a pplication. Objet i nstance c ould b e c reate b y r ight c lick o n a ny c lass a nd s elect “new ClassName()” .

3.2 execute methods of an object

After c reated a n o bject, y ou c an e xecute i ts p ublic m ethds. C lick w ith t he r ight mouse b utton o n t he o bject a nd a m enu w ith o bject o perations w ill p op u p T he menu s hows t he m ethods a vailable f or t his o bject a nd t wo s pecial o perations provided b y t he e nvironment.

4. Use-case diagram

5. JUnit Test

5.1 Create Junit Test

To c reate a J unit t est, c lick “new c lass” a nd s elect t he t ype “Unit T est” l ike t he following i mage.

The u nit t est c lass c reate i mported t he c ommon J unit l ibrary l ike j unit.Test. Common f unctions i ncluding s etUp() a nd t earDown() a re a lso i ncluded i n t he create u nit t est c lass c reated.

5.2 Create test method + Record test case

Test m ethod c ould b e c reated b y r ight c lick t he u nit t est a nd s elect “create t est method” .

Another g reat f unction p rovided b y B lueJ--‐UML i s r ecording a t est c ase. T est c ase record w ill b e c onducted a fter c reating a t est m ethod. E xecutable c ode w ill b e generated f or e very o peration r ecorded.

Adding t est c ase b y w riting c ode a re a lso w elcome i n B lueJ--‐UML. C hanges w ill b e reflected i n c lass d iagram a fter c ompliation.

5.3 Run test cases

Click t he “Run T ests” t o r un a ll t he w ritten t est c ases, o r r ight c lick t he u nit t est clas t o s elect r un a p articular t est c ase.

相关文档