UML Modeling using MagicDraw

advertisement
UML Modeling using
MagicDraw
UML for Java Programmers
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Topics?
What is UML
How UML is used
What is MagicDraw
What UML and MagicDraw provides for Java
programmers?
o we go through features supported in MagicDraw
Demo
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
What is UML?
 The UML (Unified Modeling Language) was designed
with two objectives in mind:
 To reflect the best practices of the industry
 To demystify the process of software system
modeling.(refer to Appendix A. for more details)
 UML is a graphical notation for drawing diagrams of
software concepts, which allows your development team
to quickly grasp the functionality contained within the
application.
 UML is a language and a process with neutral notation,
which means that you may use it to design your entire
OO system in any programming language and any
software development process and modeling.
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
How UML is used?
In recent years, the tools for OO software modeling have
emerged, followed by the development of the visual
modeling approach. Visual modeling means that you first
design your system by drawing diagrams (blueprints)
and then employ tools to convert those diagrams into
code.
What is visual model tools?
Today, visual modeling tools provide many features that
replace some of the more tedious tasks for the designer,
programmer, and documentation writer.
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
What is MagicDraw?
MagicDraw is a visual UML modeling and CASE tool with
teamwork support. Designed for Business Analysts,
Software Analysts, Programmers, QA Engineers, and
Documentation Writers; this dynamic and versatile
development tool facilitates analysis and design of Object
Oriented (OO) systems and databases.
MagicDraw Java version – Provides Code engineering for
Java, Java bytecode. Integration with Java IDEs.
The detailed list of MagicDraw features find at:
http://www.magicdraw.com/files/brochures/a4/MagicDrawDataSheet.pdf
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
UML Diagrams ?
In software development, the diagram is the equivalent of
a blueprint. To meet the various needs of many parties,
we often need several different “blueprints” of the same
system.
UML has three main kinds of diagrams:
 Static Diagrams: Classes, Objects, data structure
 Dynamic Diagrams: show flow of executions and change
of states
 Physical Diagrams: source file,libraries, data files
MagicDraw supports the following diagrams defined in
UML1.4: Class diagram, Object diagram, Use case diagram, Statechart diagram,
Activity diagram, Collaboration diagram, Sequence diagram, Component diagram,
Deployment diagram
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Class Diagram ?
A class diagram is a graphic representation of the static
structural model. It shows classes and interfaces, along
with their internal structure and relationships. Classes
represent types of objects that are handled in a
system.The instances of those types (objects) are
instantiated only on the runtime and are represented by an
object and interaction diagrams.
Classes can be related to each other in a number of ways:
 Associated (connected to each other)
 Dependent (one class depends/uses another class)
 Specialized (one class is a subtype of another class)
 Packaged (grouped together as a unit – package).
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Class Diagram continue…?
A class diagram does not express anything specific about
the relationships of a given object, but it does abstractly
describe the potential relationships of one object to other
objects.
A class diagram is the logical map of your existing or
future source code. FIG 1.0 BankAccount Class Diagram
BankAccount
public class BankAccount {
-acctId: String
}
-balance: double
+deposit(…): void
+withdraw(…): double
-calcInterest(…): double
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Class Diagram continue…?
class Bank {
private String city;
private int currentIndex=0;
Privat BankAccount [ ] accounts;
public void add(…) { }
public BankAccount getAccount(…) { }
}
BankAccount
-acctId: String
-balance: double
+withdraw(…): void
+deposit(…): double
-calcInterest(…): double
Bank
-city: String
-currentIndex:int
-accounts: BankAccount
+add(…): void
+getaccount(…): BankAccount
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Class Diagram continue…?
Create a class diagram
All options associated with a class can be set in the Class
Specification dialog box.
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Object Diagram ?
Classes represent types of objects that are handled in a
system.The instances of those types (objects) are
instantiated only on the runtime.
Object
Class
myAccount
BankAccount
-acctId: String
-balance: 30.00
-acctId: String
-balance: double
+deposit(…): void
+withdraw(…): double
-calcInterest(…): double
+deposit(…): void
+withdraw(…): double
-calcInterest(…): double
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
State Diagram?
Objects change their state as a request in executing a
method.. In general, The behavior of objects of a class
can be described in terms of states and events, using a
state machine connected to the class under construction.
A State Machine is a specification of the sequence of
states through which an object or an interaction goes in
response to events during its life
A State Diagram is a graph that represents a state machine
.
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Interface ?
An interface is a specifier for the externally-visible
operations of a class, component, or other classifier
(including subsystems) without specification of internal
structure. Each interface often specifies only a limited part
of the behavior of an actual class.
interface Creditchecker
“interface”
Creditchecker
{
}
public class BankAccount implements CreditChecker
{
}
BankAccount
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Abstract classes ?
In UML there are two ways to denote that a class or
method is abstract. You can write the name in italics, or
you can use the {abstract} property, both options are
shown below:
public abstract class Accounts
Accounts
{
name
private String name;
Accounts
}
{abstract}
name
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Properties?
Properties, like {abstract} can be added to any class, they
represent extra information for the class, such as
CustomerAccounts
{author=ellie,
Date=20050804,
File=account.java,
Private}
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Association ?
An Association between classes often represent instance
variables that hold references to other objects.
public class Bank
{
private BankAccount CustomersAccounts[100];
}
100
Bank
CustomersAccounts
BankAccount
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Inheritance ?
An inheritance between classes often represent instance
variables that hold references to other objects.
public class BankAccount
{
}
BankAccount
SavingAccount
CheckingAccount
public class SavingAccount extends BankAccount
{
}
public class CheckingAccount extends BankAccount
{
}
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Override Operations ?
Overriding Operation When you inherit classes from the
base class, which has abstract functions, you have to
redefine them in the inherited classes. The implement and
override operations tool will help you generate operations
that are defined as abstract in the base class.
The command Implement/Override Operations command
can be invoked in 2 cases:
 When one classifier inherits operations from the base
classifier (Generalization relationship).
 When some classifier implements Interface (Realization
relationship).
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Override Operation continue ?
To start the Implement/Override Operations tool
From the shortcut menu of the selected class,
choose Tools. Then, choose Implement/Override
Operations. The Select Operations to Implement,
Override dialog box appears.
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
MagicDraw Tools?
MagicDraw provides the following tools and wizards to help
you perform the design tasks in your job quickly and easily:
 Reports – prepares HTML, PDF, or RTF report documents describing the model.
 Class Diagram Wizard – helps to create and customize new class diagrams.
 Package Overview Diagram Wizard – generates the package dependency
diagram for packages in your project.
 Tools for Analysis – prepares diagrams and report documents of the
relationships between classes in the UML model.
 Hierarchy Diagram Wizard
 Content Diagram Wizard - generates content of diagrams that are used in the project.
 Creating Setters / Getters – creates getting and setting operators for attributes
defined in the class. Helps in analyzing the class.
 Implementing or Overriding Operations – creates defined operations down the
inheritance tree.
 And more…
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
MagicDraw Demo?
MagicDraw Basics demo : MD_viewlets_Basics.exe
This demo introduces the very basics of working with
MagicDraw: shows how to create project and diagrams,
outlines the main working environments, navigates through
elements drawing and presentation options.
Code Generation : MD90_viewlets_Codegeneration.exe
This demo will show you how to perform code
generation in the MagicDraw UML. You will get acquainted
with source code generation from model and see how model
changes are reflected in the code.
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Information on MagicDraw ?
http://www.magicdraw.com
ACM/JETT Workshop - August 4-5, 2005
UML Modeling using MagicDraw
Appendix A.
Process of software system modeling:
Without UML:
 Define problem
 Go to whiteboard
 Draw high level boxes
 Draw flowcharts(show: behaviors and state diagram)
 Write High level Specification.
 Write functional specification(function name,parameters,..)
 Code
 Analyze
 Build
 Test
With UML and UML tools such as MagicDraw:
 Define problem
 ..And use UML concept and tools such as MagicDraw to do the rest
ACM/JETT Workshop - August 4-5, 2005
Download