Upload
nouran-m-radwan
View
213
Download
1
Embed Size (px)
DESCRIPTION
UML
Citation preview
Introduction to Object-Oriented
Analysis and Design using the UML
Lab 9
Software Engineering
By Nouran Radwan
Introduction
Although UML is very well-defined, there are situations in which it needs to be customized to specific problem domains.
UML extension mechanisms are used to extend UML by:
adding new model elements,
creating new properties,
and specifying new semantics.
There are three extension mechanisms:
stereotypes, tagged values, constraints and notes.
5
Stereotypes
Stereotypes are used to extend UML to create new model elements that can be used in specific domains. e.g. elevator control system.
Place the name of the stereotype above the name of an existing UML element (if any) The name of the stereotype needs to be between «» (e.g. «node»)
«button» CancelButton
Stereotype
state
CancelButton
Stereotype in form of icon
6
Tagged Values • Define additional properties for model elements, Shown
as a tag-value pair: the tag represent the property and the value represent the value of the property.
• Tagged values can be useful for adding properties about code generation, version control, configuration management, authorship, etc.
• A tagged value is shown as a string that is enclosed by brackets {} and which consists of: the tag, a separator (the symbol =), and a value.
{author = “Bob”, Version = 2.5} Employee
name address
Two tagged values
7
Constraints and Comments
• Constraints are used to extend the semantics of UML by adding new rules, modifying existing ones, and specifying conditions.
• Comments are used to help clarify the models that are being created. e.g. comments may be used for explaining the rationale behind some design decisions.
Title Copy 1..*
Abstraction-occurrence pattern
8
Metamodel
Generalization
discriminator
Relationship
Include
Relationship
Actor
UseCase
Extend
Relationship
Open file by typing name
Open file by browsing
Open file
Browse for file
Ordinary User
Attempt to open file that does not exist
«extend» «include»
A metamodel describes information about models.
9
UML Profile Diagram
Profile diagram is structure diagram which describes lightweight extension mechanism to the UML by defining custom stereotypes, tagged values, and constraints. e.g. real-time systems, web development, etc.
• A UML profile is a specification that does one or more of the following:
- Identifies a subset of the UML metamodel.
- Specifies stereotypes and/or tagged values.
- Specifies well-formalness rules beyond those that already exist.
- Specifies semantics expressed in natural language.
10
Example of a profile
Creating a UML profile for representing basic GUI components.
We suppose that our GUI contains the following components:
Forms (which can also be dialog boxes)
Button
Constraints: (in practice, we need to be more precise)
A form can invoke a dialog box
A form as well as a dialog box can contain buttons
11
The GUI profile package
GUI Profile
Class
<<stereotype>> Form
<<stereotype>> Button
Association
<<stereotype>> Contains
<<stereotype>> DialogBox
Class and Association are part of UML metamodel
<<stereotype>> Invokes
UML Class Diagram • UML class diagram is a graphical tool that
can aid in the design of a class.
• The diagram has three main sections.
ClassName
Attributes
Methods
UML diagrams are easily converted
to Java class files. There will be more
about UML diagrams a little later.
• The class name should concisely reflect
what the class represents.
UML Class Diagram • UML diagrams are language
independent.
• UML diagrams use an independent
notation to show return types, access
modifiers, etc.
Rectangle
- width : double
+ setWidth(w : double)
Converting the UML Diagram to
Code
• Putting all of this information together,
a class file can be built easily using the
UML diagram.
• The UML diagram parts match the
class file structure.
ClassName
Attributes
Methods
class header
{
Attributes
Methods
}
Code Generation
Code generation (also called forward
engineering) is the process of generating
source from one or more classes.
Code generated is skeletal only.
Class To Code
class Employee
{
private:
int empid;
char empname;
public:
void add ();
void del ();
};
void Employee::add ()
{
}
void Employee::del ()
{
}
Reference
The elements of UML 2.0 Style, Scott Ambler.
http://www.visual-paradigm.com/product/vpuml/tutorials/packagediagram.jsp
SEG4110 – Advanced Software Design and Reengineering Lecture, UML Extension Mechanisms.