Object Oriented Software Engineering: Experiment 2 UML Modeling in Eclipse

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 15

UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA

FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

OBJECT ORIENTED SOFTWARE


ENGINEERING

Experiment 2
UML Modeling in Eclipse

CLO 1: Understanding the basics of requirements engineering, requirements


elicitation, techniques and elementary modeling techniques to develop
systems’ initial Design Model.

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Purpose:

This experiment provides an introduction to Unified Modeling Language. Student will

get basic introduction of the diagrams available for sysrem modeling. Star UML

modelling tool will also be introduced in this lab.

Objectives:

At the end of this experiment you will

1. Learn what is unified modeling langiage ?


2. Characteristics of good user requirements.
3. Components of UML.

Equipment and Components:

1. Eclipse Mars 10.0


2. Visual Paradigm 15.1

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Eclipse is truly one of the best integrated development environment (IDE). To many
software developers, Eclipse was the first IDE they ever used for serious software
development. Eclipse is easy to use, and it comes with a lot of useful features to make
implementation faster and more accurate, ultimately improving efficiency and software
stability.

Visual Paradigm is an agile development platform that provides software


developers with the wide variety of toolset they need for designing great software
products. It supports a collection of widely-used modeling notations, such as UML,
SysML, ERD and BPMN and more. Software developers can either run Visual Paradigm
in standalone manner, or to run it in embedded extension within the IDE. With this
Eclipse UML tool, developers can perform visual modeling and other agile development
activities within a unified Eclipse IDE platform. By designing your software system in
Visual Paradigm, you can generate programming source code from class diagram to an
Eclipse project. Also, you can Reverse Engineer your source code into class models in
Visual Paradigm.

In this Lab session, you will walk through the steps required to integrate Visual
Paradigm with Eclipse. The second part of the session will demonstrate the automatic
generation of Java code from UML class diagram.

Part 1:
Install Visual Paradigm, which is being provided along with the manual.

Installing Visual Paradigm in Eclipse

1. In Visual Paradigm, select Window > Integration > IDE Integration... from
the application toolbar.

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

2. In the Visual Paradigm IDE Integration window, check Eclipse


Integration.

3. Click Next.
4. Enter the path of Eclipse and click Next.

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

This begins files copying.


Note: If you see the error messages "java.io.IOException: Cannot make dirs for file...",
please restart Visual Paradigm with the Run as Administrator option. When finished
files copying, close Visual Paradigm and move on to the next section to see how to create
a Java project in Eclipse along with UML model.

Creating a Java Project


1. Start Eclipse.
2. Select File > New > Java Project from the main menu to open the New Java
Project window.
3. In the New Java Project window, enter My Project in the Project name field.

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

4. Click Finish.

Creating a UML Model for the Java Project

Now, you have an empty Java project. Let's create a UML model for it. To create a UML
model:

1. Right click on the project node in Package Explorer and select Open Visual
Paradigm from the popup menu.

2. If you see the VM Requirement dialog box, please keep the option Configure
"eclipse.ini" and restart eclipse selected and click OK to restart Eclipse, and then re-
perform the previous step to open Visual Paradigm.

3. Click OK when you are prompted to select a path to store the .vpp file. Confirm
project path

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

UML Modeling in Eclipse


Let's draw a simple class diagram. We will generate Java code from it in the next section.

1. In Diagram Navigator, right click on Class Diagram node and select New Class
Diagram from the popup menu.

2. A new diagram is created. Double click on the package header field at the top left
corner of the diagram, with a labeled <default package> in it.

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

3. Enter myapp and press Enter. From now on classes to be drawn in this diagram will be
placed in a (new) package named myapp. In practice you can also enter a nested package
structure like com.vp.myapp.

4. Create a class. Select Class from the diagram toolbar. Drag it out and put it onto the
diagram. Enter User as name and press Enter to confirm.

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

5. A user has two attributes: name and phone number. Let's add them. Right click on the
User class and select Add > Attribute from the popup menu.

 Enter name : String to create the name attribute in String type. Then press Enter to
confirm.
 Similarly, enter phoneNum : int to create the phoneNum attribute in int type. Then
press Enter to confirm it and press Esc to cancel the next attribute.

6. We want Visual Paradigm to generate getter and setter for the attributes during code
generation. Right click on the name attribute and select Create Getter and Setter from the
popup menu.

7. Repeat the previous step on the attribute phoneNum. Up to now, your class diagram
should look like this:

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Generate Java Code from UML Class


1. Let's produce Java source code from the UML class. There are several ways to achieve
this. Here let's try the one that generate code for the entire UML model. Click on the
Update Code button at the top of Diagram Navigator.

2. In the Package Explorer, expand the project node and the src folder node. The
package myapp and User class are there. Open User.java. You can see the User class filled
with attributes and its getter and setter.

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Perform Coding
In this section, you are going to build an executable application with the User class.

1. Create a Main class. In the Package Explorer, right click on the package myapp
and select New > Class from the popup menu.
2. In the New Java Class window, enter Main as class name and click Finish.

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

3. Create a static main method in the Main class that create and instantiate two User
objects. Set the name and phone number through the setter method.

4.It would be nice to add into the User class a method to print out its name and phone
number. Add a public method printInfo() in the User class.

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

5. Call printInfo() from the Main class to display the information of created users.

Running the Application


Let's run the application. Keep the Main class opened. Select Run > Run As > Java
Application from the main menu. You should see the Console view appear with users'
information printed in it.

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Updating the UML Model from Java Code


You have made some changes in source code, such as the creation of Main class and printInfo() in
User class. In order to keep the design consistent with your source code, you need to update the
UML model from code. Let's do it now.
1. In the Eclipse toolbar, click on the Update UML Model button.

2. Open the class diagram. The printInfo() method is presented in the User class.

3. For the Main class, you can find it under the Model Explorer. Drag it out and put
it below the User class.

OOSE 5th Semester-2k16-SE UET Taxila


UNIVERSITY OF ENGINEERING AND TECHNOLOGY, TAXILA
FACULTY OF TELECOMMUNICATION AND INFORMATION ENGINEERING

SOFTWARE ENGINEERING DEPARTMENT

Task:
Pick any 2 classes of your OOP Project plus crate a main class. Design them using VPP
Class Model and generate code then perform Reverse Engineering to show some
Functionality.

OOSE 5th Semester-2k16-SE UET Taxila

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy