02.12.2014 Views

Introduction to Unified Modeling Language (UML) - INSPIRATION

Introduction to Unified Modeling Language (UML) - INSPIRATION

Introduction to Unified Modeling Language (UML) - INSPIRATION

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>INSPIRATION</strong> – Spatial Data Infrastructure in the Western Balkans<br />

<strong>Introduction</strong> <strong>to</strong> <strong>Unified</strong> <strong>Modeling</strong><br />

<strong>Language</strong> (<strong>UML</strong>)<br />

3rd <strong>INSPIRATION</strong> Training<br />

December 4-5, 2012<br />

A multi-country project funded by the<br />

European Union and implemented by


Content<br />

• Basic introduction<br />

• Models<br />

• <strong>UML</strong><br />

• Diagrams<br />

• Exercises & Examples<br />

• Class diagram


Scope<br />

• Basic knowledge of <strong>UML</strong><br />

<strong>Introduction</strong><br />

of modelling<br />

and <strong>UML</strong><br />

Class model<br />

introduction<br />

& Exercises<br />

INSPIRE Data<br />

Specification<br />

on Cadastre


<strong>UML</strong> Background<br />

What are models?


<strong>UML</strong> Background<br />

What are models?<br />

• A complete description of a system from a<br />

particular perspective<br />

• Simplification of reality


Why models?<br />

• <strong>Modeling</strong> achieves four aims:<br />

• Helps you <strong>to</strong> visualize a system as you want it <strong>to</strong> be.<br />

• Permits you <strong>to</strong> specify the structure or behavior of a<br />

system.<br />

• Gives you a template that guides you in constructing a<br />

system.<br />

• Documents the decisions you have made.<br />

• You build models of complex systems because you<br />

cannot comprehend such a system in its entirety.<br />

• You build models <strong>to</strong> better understand the system<br />

you are developing.


Four Principles of <strong>Modeling</strong><br />

• The model you choose influences how the<br />

problem is attacked.<br />

Process Model<br />

Deployment Model<br />

Design Model<br />

• Every model may be expressed at different levels<br />

of precision.<br />

• The best models are connected <strong>to</strong> reality.<br />

• No single model is sufficient.


<strong>UML</strong> Background<br />

What is <strong>UML</strong>?<br />

The OMG specification states:<br />

?<br />

"The <strong>Unified</strong> <strong>Modeling</strong> <strong>Language</strong> (<strong>UML</strong>) is a graphical<br />

language for visualizing, specifying, constructing, and<br />

documenting the artifacts of a software-intensive system.<br />

The <strong>UML</strong> offers a standard way <strong>to</strong> write a system's<br />

blueprints, including conceptual things such as business<br />

processes and system functions as well as concrete things<br />

such as programming language statements, database<br />

schemas, and reusable software components."


<strong>UML</strong> Background<br />

What is <strong>UML</strong>?<br />

• <strong>UML</strong> is a language (<strong>Unified</strong> <strong>Modeling</strong><br />

<strong>Language</strong>) for models<br />

• technical and graphical specification<br />

• Graphic notation <strong>to</strong> visualize models<br />

• Not a method or procedure<br />

• Managed and created by the Object<br />

Management Group


<strong>UML</strong> Background<br />

• The <strong>UML</strong> is a language for<br />

• Visualizing<br />

• Specifying<br />

• Constructing<br />

• Documenting<br />

the artifacts of a software-intensive system.<br />

• The <strong>Unified</strong> Modelling <strong>Language</strong> (<strong>UML</strong>) is an<br />

industry standard for object oriented design<br />

notation, supported by the Object Management<br />

Group (OMG).


<strong>Language</strong> for Visualizing<br />

• Communicating conceptual models<br />

<strong>to</strong> others is prone <strong>to</strong> error unless<br />

everyone involved speaks the same<br />

language.<br />

• There are things about a software<br />

system you can’t understand unless<br />

you build models.<br />

• An explicit model facilitates communication.


<strong>Language</strong> for Specifying<br />

• The <strong>UML</strong> builds models that are precise,<br />

unambiguous, and complete.


<strong>Language</strong> for Constructing<br />

• <strong>UML</strong> models can be directly connected <strong>to</strong> a<br />

variety of programming languages.<br />

• Maps <strong>to</strong> Java, C++, Visual Basic, and so on<br />

• Tables in a RDBMS or persistent s<strong>to</strong>re in an<br />

OODBMS<br />

• Permits forward engineering<br />

• Permits reverse engineering


ƯÁ¤¹®¼¿¡ ´ëÇÑ º¸±â¸¦<br />

»ç¿ëÀÚ°¡ ¿äûÇÑ´Ù.<br />

ÈÀÏ°ü¸®ÀÚ´Â Àоî¿Â<br />

¹®¼ÀÇ Á¤º¸¸¦ ÇØ´ç ¹®¼<br />

°´Ã¼¿¡ ¼³Á¤À» ¿äûÇÑ´Ù.<br />

È¸é °´Ã¼´Â ÀоîµéÀÎ<br />

°´Ã¼µé¿¡ ´ëÇØ À̸§º°·Î<br />

Á¤·ÄÀ» ½ÃÄÑ È¸é¿¡<br />

º¸¿©ÁØ´Ù.<br />

1: Doc view request ( )<br />

9: sortByName ( )<br />

2: fetchDoc( )<br />

3: create ( )<br />

6: fillDocument ( )<br />

4: create ( )<br />

8: fillFile ( )<br />

5: readDoc ( )<br />

7: readFile ( )<br />

ºÐ»ê ȯ°æÀÇ Çϵå¿þ¾î¹× ³×Æ®¿÷À¸·ÎÀÇ Á¤º¸ ½Ã½ºÅÛ ¿¬°á ¸ðµ¨<br />

- À©µµ¿ì 95 : ŬóÀ̾ðÆ®<br />

- À©µµ¿ì NT: ÀÀ¿ë¼¹ö<br />

- À¯´Ð½º ¸Ó½Å: ÀÀ¿ë ¼¹ö ¹× µ¥ÀÌŸ ¼¹ö, Åë½Å ¼¹ö<br />

- IBM ¸ÞÀÎÇÁ·¹ÀÓ: µ¥ÀÌŸ ¼¹ö, Åë½Å ¼¹ö<br />

Window95<br />

¹®¼°ü¸®<br />

ŬóÀ̾ðÆ®.EXE<br />

FileMgr<br />

fetchDoc( )<br />

Reposi<strong>to</strong>ry<br />

(from Persistence)<br />

rep<br />

name : char * = 0<br />

readDoc( )<br />

readFile( )<br />

Windows<br />

NT<br />

sortByName( )<br />

Windows<br />

NT<br />

¹®¼°ü¸® ¿£Áø.EXE<br />

FileList<br />

add( )<br />

delete( )<br />

read( )<br />

File<br />

Windows95<br />

DocumentList<br />

add( )<br />

IBM<br />

Mainframe<br />

µ¥ÀÌŸº£À̽º¼¹ö<br />

delete( )<br />

1<br />

fList<br />

Solaris<br />

ÀÀ¿ë¼¹ö.EXE<br />

GrpFile<br />

read( )<br />

open( )<br />

create( )<br />

fillFile( )<br />

get( )<br />

name : int<br />

docid : int<br />

open( )<br />

close( )<br />

read( )<br />

Document<br />

numField : int<br />

sortFileList( )<br />

create( )<br />

Windows95<br />

¹®¼°ü¸® ¾ÖÇø´<br />

fillDocument( )<br />

Alpha<br />

UNIX<br />

code..<br />

read() fill the<br />

<strong>Language</strong> for Documenting<br />

• The <strong>UML</strong> addresses documentation of system architecture,<br />

requirements, tests, project planning, and release management.<br />

Use Case Diagram<br />

Deployment Diagram<br />

Use Case 1<br />

Ac<strong>to</strong>r A<br />

Use Case 2<br />

Ac<strong>to</strong>r B<br />

Use Case 3<br />

user<br />

mainWnd fileMgr :<br />

FileMgr<br />

document :<br />

Document<br />

gFile<br />

reposi<strong>to</strong>ry<br />

Sequence Diagram<br />

Class Diagram


His<strong>to</strong>ry of the <strong>UML</strong>


Diagrams<br />

• Diagrams graphically depict a view of a part of your<br />

model.<br />

• Different diagrams represent different views of the<br />

system that you are developing.<br />

• A model element will appear on one or more diagrams.


<strong>UML</strong> Diagrams<br />

• <strong>UML</strong> 2.2<br />

• 14 different types of diagrams<br />

• 2 different groups<br />

• Behavior & Interaction models<br />

• Structural models


<strong>UML</strong> Diagrams


Key Diagrams in <strong>UML</strong><br />

Requirements<br />

Use Case Diagrams<br />

System Structure<br />

System Behaviour<br />

Class Diagrams<br />

Collaboration Diagrams<br />

Interaction Diagrams<br />

Activity Diagrams<br />

State Charts


Different diagrams of system<br />

for different people<br />

Logical View<br />

Implementation View<br />

Analysts/Designers<br />

Structure<br />

Use-Case View<br />

End-user<br />

Functionality<br />

Programmers<br />

Software management<br />

Process View<br />

Deployment View<br />

System integra<strong>to</strong>rs<br />

Performance, scalability, throughput<br />

System engineering<br />

System <strong>to</strong>pology, delivery,<br />

installation, communication


What is a Use-Case Model?<br />

A use-case model:<br />

• Is a model of a system’s intended functions and its<br />

environment<br />

• Serves as a contract between the cus<strong>to</strong>mer and the<br />

developers<br />

• Contains the following diagrams:<br />

• Use case: Shows a set of use cases and ac<strong>to</strong>rs and their<br />

relationships<br />

• Activity: Shows the flow of events within a use case<br />

• Sequence: Shows how a use case will be implemented in terms of<br />

collaborating objects


Use-Case Diagram<br />

View Report Card<br />

Student<br />

Register for Courses<br />

Login<br />

Course Catalog<br />

Registrar<br />

Maintain Professor<br />

Information<br />

Maintain Student<br />

Information<br />

Professor<br />

Select Courses <strong>to</strong><br />

Teach<br />

Submit Grades<br />

Close Registration<br />

Billing System


Activity Diagram<br />

Action<br />

A step in the flow of events<br />

Decision<br />

Flows split based on a guard<br />

condition<br />

Fork<br />

Beginning of concurrent flows<br />

Join<br />

End of concurrent flow<br />

Flow<br />

Show the sequence of<br />

activities


Activity Diagram (Example)<br />

Concurrent<br />

Threads<br />

Guard<br />

Condition<br />

Check<br />

Schedule<br />

Select Course<br />

[ add course ]<br />

[ delete course ]<br />

Check<br />

Pre-requisites<br />

[ checks completed ] [ checks failed ]<br />

Decision<br />

Delete Course<br />

Activity/Action<br />

Synchronization<br />

Bar (Fork)<br />

Synchronization<br />

Bar (Join)<br />

Assign <strong>to</strong><br />

Course<br />

Resolve<br />

Conflicts<br />

Transition<br />

Update<br />

Schedule


What is a Design Model?<br />

A design model:<br />

• Describes the realization of use cases in terms of design<br />

elements<br />

• Describes the design of the application<br />

• Contains the following diagrams:<br />

• Class: Shows <strong>UML</strong> classes and relationships<br />

• Component: Shows the structure of elements in the<br />

implementation model<br />

• Communication and Sequence: Show how objects and classes<br />

interact<br />

• State Machine: Shows event-driven behavior


Class Diagram<br />

• Class diagrams show the static structure of the<br />

model resp. system<br />

• Classes<br />

• Attributes<br />

• Relationships <strong>to</strong> other classes<br />

• Class diagrams do not show temporal<br />

information<br />

• INSPIRE data specifications


Class Diagram<br />

Class<br />

A description of a set<br />

of objects<br />

Attribute<br />

Named property of<br />

a class<br />

Operation<br />

Class behavior<br />

Generalization<br />

Shows an inheritance<br />

relationship<br />

Aggregation<br />

Represents a part-whole<br />

relationship


Sequence Diagram<br />

• used <strong>to</strong> show how objects interact <strong>to</strong><br />

perform the behavior of all or part of a use<br />

case as part of a use-case realization


Sequence Diagram<br />

Object/Class<br />

Shows the<br />

object/class involved<br />

in the interaction<br />

Messages<br />

Show data exchanged<br />

between objects<br />

Execution Occurrence<br />

Shows object executing<br />

Lifeline<br />

Shows the life of the object


Sequence Diagram<br />

(Example)<br />

:RegisterForCoursesForm :RegistrationController SWTSU Catalog :<br />

CourseCatalogSystem<br />

: Student : Course Catalog<br />

1: create schedule( )<br />

2: get course offerings( )<br />

3: get course offerings(for Semester)<br />

5: display course offerings( )<br />

4: get course offerings( )<br />

6: display blank schedule( )<br />

ref<br />

Select Offerings


Sequence Diagram<br />

Combined Fragments<br />

Interaction Use (ref)<br />

References another interaction<br />

Optional Fragment<br />

(opt)<br />

Executed if guard condition<br />

evaluates <strong>to</strong> true<br />

Loop (loop)<br />

Executed as long as the first<br />

guard condition<br />

evaluates <strong>to</strong> true


Communication Diagram<br />

• Collaboration diagram<br />

• provide another way <strong>to</strong> show how objects<br />

interact <strong>to</strong> perform the behavior of a<br />

particular use case or a part of a use case.<br />

Where sequence diagrams emphasize the<br />

interactions of objects over time,<br />

communication diagrams are designed <strong>to</strong><br />

emphasize the relationships between objects


Communication Diagram<br />

Object/Class<br />

Shows the<br />

object/class involved<br />

in the interaction<br />

Message<br />

Shows data<br />

exchanged<br />

between objects


Communication Diagram<br />

Messages<br />

5: display course offerings( )<br />

6: display blank schedule( )<br />

1: create schedule( )<br />

: RegisterForCoursesForm<br />

Links<br />

: Course Catalog<br />

: Student<br />

2: get course offerings( )<br />

4: get course offerings( )<br />

3: get course offerings(forSemester)<br />

: RegistrationController : CourseCatalogSystem


Component Diagram<br />

• It shows the runtime structure of the<br />

system at the level of software<br />

components. Components are the modular<br />

parts of the system and are made up of<br />

groups of related objects that are hidden<br />

behind an external interface.


Component Diagram<br />

Component<br />

Modular parts of the system<br />

Class<br />

Included <strong>to</strong> show implementation<br />

relationships.


Deployment Diagram<br />

• Deployment diagrams show the<br />

deployment architecture of the system,<br />

that is, which of the system’s software<br />

artifacts reside on which pieces of<br />

hardware.


Deployment Diagram<br />

Artifact<br />

Represents a physical file<br />

Owned Element<br />

Relationship<br />

Shows another way of<br />

showing nested elements<br />

Node<br />

Represents a<br />

physical machine


How Many Diagrams?<br />

• Depends:<br />

• You use diagrams <strong>to</strong> visualize the system from different<br />

perspectives.<br />

• No complex system can be unders<strong>to</strong>od in its entirety from one<br />

perspective.<br />

• Diagrams are used for communication<br />

• Model elements will appear on one or more<br />

diagrams.<br />

• For example, a class may appear on one or more class diagrams, be<br />

represented in a state machine diagram, and have instances appear<br />

on a sequence diagram.<br />

• Each diagram will provide a different perspective.


<strong>UML</strong> – Exercise


<strong>UML</strong> – Exercise<br />

• Class diagram<br />

• INSPIRE Data<br />

Specifications<br />

• Foundation for<br />

other structure<br />

diagrams<br />

• Classification of<br />

reality


<strong>UML</strong> Exercise<br />

• The class diagram<br />

• Class (and objects)<br />

• Relationship<br />

• Package (advanced)<br />

• Interfaces (advanced)


<strong>UML</strong> Exercise<br />

• The class<br />

• Summarize a number of objects with the same<br />

behavior and semantics<br />

• Abstraction of entities<br />

• Semantic concept with common attributes and<br />

operations


<strong>UML</strong> Exercise<br />

• The class<br />

• Abstraction of entities<br />

class Tree<br />

«FeatureClass»<br />

Tree<br />

- TreeAge :int<br />

- TreeType :char


<strong>UML</strong> Exercise<br />

• The class<br />

Class name<br />

Class attributes<br />

Class operations


<strong>UML</strong> Exercise<br />

• The class attribute<br />

Attribute name<br />

Data type<br />

E.g.:<br />

-Integer<br />

- LongInt<br />

- Double<br />

- Char<br />

- Date<br />

- Boolean<br />

- String<br />

- Geometry<br />

- …


<strong>UML</strong> Exercise<br />

• The class operations<br />

Attribute name<br />

Expected operation input<br />

Data type


<strong>UML</strong> Exercise<br />

• Exercise #1 – The Class<br />

• Please develop/draw the class “Cadastral_Parcel”<br />

• What common characteristics (attribute: datatype)<br />

should the concept “Cadastral_Parcel” have?<br />

class Exercise #1<br />

«featureType»<br />

CadastralParcel<br />

?


Group 1<br />

• Class: Parcel<br />

• Attributes:<br />

• Object no.<br />

• Number<br />

• Cadastral municipality<br />

• Land use<br />

• Number of building<br />

• Address<br />

• Area<br />

• Owner


Group 2<br />

• The same as g1, just no address


<strong>UML</strong> Exercise<br />

• Exercise #1 – The Class<br />

• Multiple solutions possible<br />

class Exercise #1<br />

«featureType»<br />

CadastralParcel<br />

- Address :char<br />

- APN :char<br />

- Boundary :GM_Surface<br />

- Centroid :GM_Point


<strong>UML</strong> Exercise<br />

• Exercise #1 – The Class<br />

• INSPIRE Data Specifications on Cadastral<br />

• Geometry<br />

• Label<br />

• National cadastral reference<br />

• Area value (optional)<br />

• Reference Point (optional)


<strong>UML</strong> Exercise<br />

• Relations<br />

Relation?


<strong>UML</strong> Exercise<br />

• Relations<br />

• Associations<br />

• Generalisations<br />

• Aggregations<br />

• Compositions


<strong>UML</strong> Exercise<br />

• Associations<br />

• Implies that two classes have a relationship<br />

• General relationship connec<strong>to</strong>r<br />

• Target/Source roles<br />

• Cardinality<br />

• Directions<br />

• Constrains


<strong>UML</strong> Exercise<br />

• Associations<br />

class Tree<br />

«FeatureType»<br />

Tree<br />

+cutted by<br />

+cuts<br />

«FeatureTyp...<br />

Woodcutter<br />

- TreeAge :int<br />

- TreeType :char<br />

1..*<br />

1..*<br />

- Gender :char<br />

- Name :char


<strong>UML</strong> Exercise<br />

• Generalisations<br />

• Indicated inheritance<br />

• Target/Source roles (e.g. isPartOf)<br />

• Cardinality<br />

• Constrains<br />

• Source inherits targets characteristic


<strong>UML</strong> Exercise<br />

• Generalisations<br />

class Tree<br />

«FeatureType»<br />

Tree<br />

- TreeAge :int<br />

- TreeType :char<br />

+cutted by<br />

1..*<br />

+cuts<br />

1..*<br />

«FeatureType»<br />

Woodcutter<br />

- LicenceNumber :int<br />

Woodcutter inherits<br />

attributes from Person<br />

«FeatureType»<br />

Person<br />

- Gender :char<br />

- Name :char


<strong>UML</strong> Exercise<br />

• Aggregations & Compositions<br />

• Indicates that the lower concept is part of a higher<br />

concept<br />

• Aggregation: Lower concept ISN’T necessary for<br />

existence of higher concept<br />

• Composition: Lower concept IS necessary for existence<br />

of higher concept


<strong>UML</strong> Exercise<br />

• Aggregations & Compositions<br />

Compositio<br />

n<br />

class Tree<br />

Aggregation<br />

«FeatureType»<br />

Forest<br />

«FeatureType»<br />

Employees<br />

+consistsOf 1..*<br />

+has 0..*<br />

+isPar<strong>to</strong>f<br />

+isPartOf<br />

«FeatureType»<br />

Tree<br />

+cutted by<br />

+cuts<br />

«FeatureType»<br />

Woodcutter<br />

«FeatureType»<br />

Person<br />

- TreeAge :int<br />

- TreeType :char<br />

1..*<br />

1..*<br />

- LicenceNumber :int<br />

- Gender :char<br />

- Name :char


<strong>UML</strong> Exercise<br />

• Exercise #2 – The relationship types<br />

• Imagine you have 3 different classes<br />

• CadastralParcel<br />

• Core class<br />

• Is part of several(!) administrative zones (different levels of<br />

hierarchy)<br />

• CadastralBoundary<br />

• Indicates measured boundary of CadastralParcel<br />

• AdministrativeZone<br />

• Administrative zones with different hierarchal levels which<br />

existence doesn’t depend on CadastralParcel<br />

• Please develop diagram using relationship types and<br />

classes with (some) attributes!


Exercise 2<br />

Administrative<br />

Zone<br />

Cadastral<br />

Boundary<br />

Cadastral Parcel


<strong>UML</strong> Exercise<br />

• Exercise #2 – The relationship types<br />

• Again there are multiple solutions<br />

class Exercise #2<br />

- Label :char<br />

- ... :...<br />

«featureType»<br />

CadastralZone<br />

?<br />

«featureType»<br />

CadastralParcel<br />

- Address :char<br />

- ParcelNumber :char<br />

- ... :...<br />

«featureType»<br />

CadastralBoundary<br />

- Geometry :GM_curve<br />

- ... :...


<strong>UML</strong> Exercise<br />

• Exercise #2 – The relationship types<br />

• There are multiple solutions<br />

• One example:<br />

class Exercise #2<br />

«featureType»<br />

CadastralBoundary<br />

+is border<br />

+hasBorder<br />

«featureType»<br />

CadastralParcel<br />

+isPar<strong>to</strong>f<br />

+Contains<br />

«featureType»<br />

Administrativ eZone<br />

- Geometry :GM_curve<br />

- ... :...<br />

1..2<br />

1..*<br />

- Address :char<br />

- ParcelNumber :char<br />

- ... :...<br />

1..*<br />

0..*<br />

- Label :char<br />

- Geometry :GM_surface<br />

- ... :...


INSPIRE Cadastre<br />

• INSPIRE Data specifications on cadastral<br />

• http://inspire.jrc.ec.europa.eu/


References<br />

• OMG - <strong>UML</strong><br />

• http://www.uml.org/<br />

• Sparx Systems<br />

• http://www.sparxsystems.com/resources/uml2_t<br />

u<strong>to</strong>rial/index.html<br />

• Learners support publication<br />

• http://www.lsp4you.com/seminar.htm


Contact & Information<br />

Christian Ansorge<br />

+43-(0)1-313 04/3160<br />

christian.ansorge@umweltbundesamt.at<br />

Ivica Skender<br />

+385-(0)91-33667-120<br />

ivica.skender@gdi.net<br />

Bečići ■ December 5, 2012<br />

69

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!