uml - part 3
DESCRIPTION
UML - Part 3. Modeling Element Structural things Behavioral things Grouping things Annotational things Relationships Dependency Association Generalization Realization. 3. Diagram Class diagram Object diagram Use case diagram Sequence diagram Collaboration diagram - PowerPoint PPT PresentationTRANSCRIPT
UML, page 2
Building Blocks of the UMLBuilding Blocks of the UML1. Modeling Element
1. Structural things2. Behavioral things3. Grouping things4. Annotational things
2. Relationships1. Dependency2. Association3. Generalization4. Realization
3. Diagram1. Class diagram2. Object diagram3. Use case diagram4. Sequence diagram5. Collaboration
diagram6. Statechart diagram7. Activity diagram8. Component diagram9. Deployment diagram
UML, page 3
3 Diagrams3 Diagrams
• A diagram is typically a view of a part of the model, showing modeling elements and some of the relationships between them.
• A diagram do not have to be complete, some elements may be missing or presented in a simplified fashion.
• UML: ”A well-formed model is one that is semantically self-consistent and in harmony with all related models.”
UML, page 4
There are 9 types of diagrams inThere are 9 types of diagrams in UMLUML
SequenceDiagrams
Dynamic views Static views
CollaborationDiagrams
ActivityDiagrams
StatechartDiagrams
ClassDiagrams
ObjectDiagrams
ComponentDiagrams
DeploymentDiagrams
Use CaseDiagrams
Model
Some part ofthe model might not be visible on
any diagram
UML, page 5
3.1 Use case diagram3.1 Use case diagram
User
register a person
edit a registration/delete a registration
navigate/viewthe register
”include”view next
person
view previousperson
”include”
”include”
actor
association
use casesystem boundary
include relationship
UML, page 6
Use Case Diagram - One More ExampleUse Case Diagram - One More Example
Make/edit course Lecturer
Student Register for course
Register as studentPerson
<<become>>
Adm
Register for exam
InstructorWorking with courseCourseParticipant
<<become>>
”A use case is a specific way of usingthe system by performing somepart of the functionality.Each use case constitutes a completecourse of events initiated by an actor,and it specifies the interaction thattakes place between an actor andthe system....”
I. Jacobson
UML, page 7
3.2 Class Diagram3.2 Class Diagram
name : Stringdescription : String
name : Stringemail : StringhomePage : String
*
CourseModule
name : Stringdescription : String
1..*
Student StudentCourseProfile
finished : boolean
Course1 *Person
1 *tech. responsible for
1
1
**
1
*
responsible for
When a student register for course a StudentCourseProfile
object will be made!
UML, page 8
A Class DiagramA Class DiagramWith NavigationWith Navigation
name : Stringdescription : String
name : Stringimail : StringhomePage : String
*
CourseModule
name : Stringdescription : String
1..*
Student
Course1 *responsible forPerson
1 *tech. responsible for
1
1
1
StudentCourseProfile
finished : boolean
***
UML, page 9
A Class Diagram - Mapping to JavaA Class Diagram - Mapping to Java
name : Stringdescription : String
name : Stringimail : StringhomePage : String
Student
Course1 *responsible forPerson
1 *tech. responsible for
1
1
StudentCourseProfile
finished : boolean
**
public class Person { protected String name; protected String imail; protected String homePage;//// Navigation protected Course[] responsibleFor; protected Course[] techResponsibleFor;
public Person() { }}
public class Person { protected String name; protected String imail; protected String homePage;//// Navigation protected Course[] responsibleFor; protected Course[] techResponsibleFor;
public Person() { }}
public class Student extends Person {//// Navigation public StudentCourseProfile[] studentCourseProfile;
public Student() { }}
public class Student extends Person {//// Navigation public StudentCourseProfile[] studentCourseProfile;
public Student() { }}
UML, page 10
A Class Diagram - Example With InterfaceA Class Diagram - Example With Interface
Person
edit()write()read()
RegisterIStorable
edit()write()read()
<<Interface>>
0..*
-reg
0..*
public void read(){ terminal.print("Name: ");
name = terminal.readLine(); ...}
relization
Person
edit()write()read()Storable
Register
relization/implements
dependency
Two different representationof nearly the same
UML, page 11
A Class Diagram -A Class Diagram -One More Example With InterfaceOne More Example With Interface
Person
IStorableRegister
ISortable
isLess(theOther : ISortable) : booleanisEqual(theOther : ISortable) : booleanisGreater(theOther : ISortable) : boolean
<<Interface>>
SortableRegister
UML, page 12
3.3 Object Diagram -3.3 Object Diagram -Capture Instances and LinksCapture Instances and Links
Company
Class Object
Possible object
name
noOfEmploees : intHiA: Company
noOfEmploees=600
object classattributewith value
UML, page 13
Object Diagram with LinksObject Diagram with Links
HiA: Company
Engineering : Department
Grooseveien:Office
:LocatedAt
Language: Department
Gimlemoen:Office
:LocatedAtCompany
Department OfficeLocatedAt
1
1..*
1..**
Class Diagram Object Diagram
Possibleobject diagram
Link - A link is an instance of an association,analogous to an object being an instance of a class.
UML, page 14
HiA:Comany Gimlemoen:Office
noOfEmploees = 600
Object diagram and Rational Rose 2000Object diagram and Rational Rose 2000
Rational Rose 2000 does not have object diagrams,but you can achieve much the same with a collobartion diagram
You can not specify attributes inside object;One solution to this short-coming is to use a comment!
UML, page 15
3.4 Sequence diagram3.4 Sequence diagram
<name,e-mail,..>
<command r>
registeruser controllerViewer
person”create”
insert(person)
setData(name, ..)
UML, page 16
3.5 Collaboration diagram3.5 Collaboration diagram
register
personuser
1: register()
controllerViewer
1.1: data := getData()
1.3: setDate(data)1.2: ”create”
1.4: insert(person)
UML, page 17
3.6 Statechart diagram 3.6 Statechart diagram
StateChart for microwaveoven "control unit"
Simple microwave oven:- Power can be on or off- Time can be set after the power has been turned on
Waiting
do/ display("Off")exit/ display("Time?")
Set time
do/ get numberexit/ ^timer.setTime(timeRead)
Disabled
do/ display("Close Door")
Operating
do/ display ("time left")exit/ ^heattingElement.powerOff()entry/ ^heatingElement.powerOn()
[ Door open ] [ Door closed ]
Door closed
Door open
End
Time out
Power turned on
UML, page 18
Statechart for AppletStatechart for Applet
init/init()
start/start()
NotLoaded
Loaded
Running
destroy/destroy()
stop/stop()
start/start()
Stopped
UML, page 19
3.7 Activity diagram3.7 Activity diagram - -Capture Dynamic Behaviour (Activity-oriented)Capture Dynamic Behaviour (Activity-oriented)
UML, page 20
Activity diagram -Activity diagram -One More ExampleOne More Example
activity
product of activity
UML, page 21
Activity diagram - One More ExampleActivity diagram - One More Exampleuser controller person register
request registration
create person (object)
supply person-data
forward person-data
process person-data
insert person
UML, page 22
3.8 Component diagram -3.8 Component diagram -Captures the Physical Structure of the ImplementationCaptures the Physical Structure of the Implementation
applet1.class
Demo.html applet2.class
logo.gif
applet1.java
applet2.java
UML, page 23
Component diagram -Component diagram -One More ExampleOne More Example
Person.class Register.class
ISortable
UML, page 24
3.9 Deployment diagram3.9 Deployment diagram
ExtendedVLAN
”network” LAN
”PC””PC”
”Server”
UML, page 25
server1:
client:
Multi-tier Architecture
- MVC -view:
browser/jsp/servletcontroller:jsp/servletmodel:
businessObjects
j1:Jsp s1:Servlet
server2:
browser:InternetInternet
:WebServer
:DB
:ServletContainer
s2:Servlet j2:Jsp
b1:BusinessObject b3:BusinessObject
b4:BusinessObject b2:BusinessObject
IntranetIntranet
:html:html
UML, page 26
ReferencesReferences• [1] Grady Booch, James Rumbaugh and Ivar Jacobson:
The Unified Modeling Language User Guide.Addison-Wesley, 1999
• James Rumbaugh, Michael Blaha, William Premerlani, Frederick Eddy and William Lorenzen: Object-Oriented Modeling and Design. Prentice Hall, 1991
• Martin Fowler with Kendall Scott: UML Distilled.Addison-Wesley, 1997
• Terry Quatrani: Visual Modeling with Rational Rose and UML.Addison-Wesley, 1998
• Ari Jaaksi: A Method for Your First Object-Oriented Project. JOOP - The Journal of Object-Oriented Programming, Januar 1998
• Rational software: http://www.rational.com/uml/documentation.html