April 2006

102
Amirkabir University of Technology Amirkabir University of Technology Department of Computer engineering & IT Department of Computer engineering & IT Software Engineering II Software Engineering II Unified modeling Language Unified modeling Language (UML) (UML) April 2006 In the Name of GOD

description

In the Name of GOD. Amirkabir University of Technology Department of Computer engineering & IT Software Engineering II Unified modeling Language (UML). April 2006. Table of Contents. References OO Paradigm Modeling Overview of UML. References. - PowerPoint PPT Presentation

Transcript of April 2006

Page 1: April 2006

Amirkabir University of TechnologyAmirkabir University of Technology

Department of Computer engineering & ITDepartment of Computer engineering & IT

Software Engineering IISoftware Engineering II

Unified modeling LanguageUnified modeling Language

(UML)(UML)

April 2006

In the Name of GOD

Page 2: April 2006

2Unified Modeling Language

Table of ContentsTable of Contents

References

OO Paradigm

Modeling

Overview of UML

Page 3: April 2006

3Unified Modeling Language

ReferencesReferences

1- “The Unified Modeling Language User Guide”, Grady Booch, Jame

s Rumbaugh, Ivar Jacobson

2- “The Unified Modeling Language Reference Guide”, Grady Booch,

James Rumbaugh, Ivar Jacobson

3- “Mastering UML with Rational Rose 2002”, Wendey Rogss, 200

2, Cybex

Page 4: April 2006

4Unified Modeling Language

OO ParadigmOO Paradigm

در شي گرايي واحد برنامه ما کالس است که طي آن اطالعات و

اصول رفتار يک موجوديت پياده سازي مي شود. :

Encapsulation:

کپسوله کردن بخشي از اطالعات و رفتارهايي که بر اساس آن

.اطالعات صورت مي گيرد درون يک شيء

:مزايا

محدود کردن تاثيرات تغييرات سيستم

مخفي کردن اطالعات

Page 5: April 2006

5Unified Modeling Language

OO ParadigmOO Paradigm

Inheritance:

در شي گرايي ارث بري مکانيزمي است که بر اساس آن مي توان يک شي

بر اساس شي ديگر ايجاد کرد که در آن شي فرزند کيفيت شي پدر را به

.ارث خواهد برد. تغييرات در پدر بر فرزندان موثر است و نه بالعکس

Polymorphism:

چند ريختي به معني داشتن چند شکل مختلف براي پياده سازي يک عملکرد

.است

Page 6: April 2006

6Unified Modeling Language

ModelingModeling

Model:

تکنيک ثابت شده و صوری برای نمايش و بازنمايي اطالعات تعريف:

نمايش ساده واقعيت هدف:

Why Modeling:

Big Problem n Smaller Problem

:اهداف

نمايش وضعيت فعلي / آتي -1

تعيين ساختار و عملکرد سيستم -2

مبنايي براي توليد (نرم افزار) -3

مستند سازي-4

Page 7: April 2006

7Unified Modeling Language

ModelingModeling

:اصول مدلسازي

.انتخاب مدل در نتيجه نهايي تاثير دارد -1

.هر مدل محدوديت برای ميزان نمايش دارد -2

- بهترين مدل : شبيه ترين به واقعيت3

- ديدگاه هاي مختلف درباره سيستم وجود دارد4

Page 8: April 2006

8Unified Modeling Language

ModelingModeling

:UMLديدگاه هاي مختلف سيستم در

1- Use Case View:

- Requirements and Features - Analyst

2- Design View:

- Problem and Solution - Designer and Programmer

3- Process View:

- Multithreading - Programmer

4- Implementation View:

- Technologies - Programmer

5- Deployment View:

- Hardware and Topology - Designer and Technologist

ها مهمتر باشند.viewبر حسب نوع برنامه، ممکن است بعضي نکته:

Page 9: April 2006

9Unified Modeling Language

ModelingModeling

Page 10: April 2006

10Unified Modeling Language

ModelingModeling

:Rational Roseديدگاه هاي مختلف سيستم در

1- Use Case View:

Use Case View in UML Standard

2- Logic View:

Design View and Process View in UML Standard

3- Component View:

Implementation View in UML Standard

4- Deployment View:

Deployment View in UML Standard

Page 11: April 2006

11Unified Modeling Language

Overview of UMLOverview of UML

هستند:UMLسه مورد زير مباحث اصلي

1- Basic Building Blocks:

The Vocabulary of the UML

2- Rules:

Specify the Well-formed Model: Semantically

Self-consistent and in harmony with all its related models.

3- Common Mechanisms:

An UML model is made simpler by presence of common mechanisms

Page 12: April 2006

12Unified Modeling Language

Basic Building BlocksBasic Building Blocks

1- Things

Structural Things:

- Class - Interface

- Collaboration - Use Case

- Active Class - Component

- Node

Behavioral Things:

- Message - State

Grouping Things:

- Package

Annotational Things:

- Note

Page 13: April 2006

13Unified Modeling Language

Basic Building BlocksBasic Building Blocks

2- Relationships

Dependency رابطه استفاده چيزی از ديگري

Association رابطه ساختاري

Generalization (is-a) رابطه تعميم

Realization رابطه تحقق بخشيدن

Page 14: April 2006

14Unified Modeling Language

Basic Building BlocksBasic Building Blocks

3- Diagrams

1- Class Diagram

2- Object Diagram

3- Use case Diagram

4- Sequence Diagram

5- Collaboration Diagram

6- Statechart Diagram

7- Activity Diagram

8- Component Diagram

9- Deployment Diagram

Page 15: April 2006

15Unified Modeling Language

Basic Building Blocks - Basic Building Blocks - structural thingsstructural things

1- Class

تعريف: اشياء که دارای خصوصيات مشابه، عملکرد مشابه، رابطه

مشابه يا مفهوم مشابه هستند.

نکته: اگر تعداد عملکردها زياد و نامرتبط با هم باشند، بهتر است کالس به

کالسهاي ديگر شکسته شود.

Page 16: April 2006

16Unified Modeling Language

Basic Building Blocks - Basic Building Blocks - structural thingsstructural things

2- Interface

External Behavior Visibleتعريف:

بدون پياده سازي)Specification(فقط تعيين مشخصات

دارند و از بيرون قابل Publicنکته: در کالسهاي عادي که فقط يک قسمت

مشخص نمي کنيم.Interfaceدسترسي هستند.

Page 17: April 2006

17Unified Modeling Language

Basic Building Blocks - Basic Building Blocks - structural thingsstructural things

3- Use Case

قرار ميدهدActor مجموعه عملياتهايي که نتيجه اي را در اختيار تعريف:

با هم متفاوتند. يک متد از يک کالس اصلي مي تواند يک Use Case و Classنکته: - مفهموم

Use Case .باشد

-Actor کالسي از سيستم که :Active است و کار خاص مفيدي انجام ميدهد. ( فرد، سخت

افزار، سيستم يا زير سيستم)

Page 18: April 2006

18Unified Modeling Language

Basic Building Blocks - Basic Building Blocks - structural thingsstructural things

4- Collaboration

مجموعه از کالسهايي که با هم همکاري مي کنند تا نتيجه اي بدست تعريف:

آيد.

يک به يک است.Collaboration و Use Caseنکته: - معموال رابطه

)nبه 1( رابطه کلي = تجزيه شودCollaboration کلي تر باشد ميتواند به چند Use Case- اگر

- 1 Use Case --- 0 … n Collaboration

-1 Collaboration --- 1 … n Class

-1 Class --- 1 … n Collaboration

استفاده ميشود. Use Case Realization از نام Rational Rose در -

Page 19: April 2006

19Unified Modeling Language

Basic Building Blocks - Basic Building Blocks - structural thingsstructural things

5- Active Class

کالسي که از ديدگاه کاربر نهايي خودکار اجرا ميشود و کنترل تعريف:

فعاليتهايش را خودش بر عهده دارد نه مثل کالس عادي که با درخواست

کالس ديگر سرويسي ارائه کند.

نکته: - معموال برنامه هاي سيستمي مانند سيستم عامل و سيستم مديريت پايگاه داده،

دارند.Active Classسرويسهايي از نوع

Page 20: April 2006

20Unified Modeling Language

Basic Building Blocks - Basic Building Blocks - structural thingsstructural things

6- Component

را Interface يک عنصر فيزيکي و با قابليت جايگزيني که مجموعه اي از تعريف:

پشتيباني مي کند.

Page 21: April 2006

21Unified Modeling Language

Basic Building Blocks - Basic Building Blocks - structural thingsstructural things

7- Node

عنصر سخت افزاری که امکان پردازش دارد. تعريف:

Page 22: April 2006

22Unified Modeling Language

Basic Building Blocks – Basic Building Blocks – Behavioral thingBehavioral thing

1- Message

از شيء يک کالسOperation فراخواني تعريف:

Page 23: April 2006

23Unified Modeling Language

Basic Building Blocks – Basic Building Blocks – Behavioral thingBehavioral thing

2- State Machine

وضعيت های مختلف يک شيء را نشان ميدهد. متشکل از تعريف:

چهار جزء است:

1 -State 2- Event 3- Response 4شيء -

Page 24: April 2006

24Unified Modeling Language

Basic Building Blocks – Basic Building Blocks – Grouping ThingGrouping Thing

1- Package

تعريف: نوعي گروه بندي منطقي است که هر جزيي را شامل مي

شود.

Package ها داراي ساختار سلسله مراتبي هستند و ميتوانند تودرتو

باشند.

Page 25: April 2006

25Unified Modeling Language

Basic Building Blocks – Basic Building Blocks – Annotational ThingAnnotational Thing

1- Note

تعريف:توضيحات درباره دياگرام ها و اجزاء آنها

Rational Roseدر

می توان از گزينه هاي

Document Window

نيز استفادهAttach Fileو

کرد.

Page 26: April 2006

26Unified Modeling Language

RelationshipsRelationships

1- Association

تعريف:رابطه ساختاري بين کالس ها

1. a relationship between classes indicates some meaningful

and interesting connection

2. a structural relationship that describes a set of links, a link

being a connection between objects.

Page 27: April 2006

27Unified Modeling Language

RelationshipsRelationships

1- Association

Association Notation:

Page 28: April 2006

28Unified Modeling Language

RelationshipsRelationships

1- Association

Multiplicity: Multiplicity A defines how many instances of type A can be associated with

one instance of type B at some point

Mother Child1 1..*

Actor Film* *

performs-in

Game Player1 2..6

برای مختلف ها : Multiplicity حالت

Exactly one - 1 Zero or one - 0..1 Many - 0..* or * One or more - 1..* Exact Number - e.g. 3..4 or 6 Or a complex relationship – e.g.

0..1, 3..4, 6..* would mean any number of objects other than 2 or 5

Page 29: April 2006

29Unified Modeling Language

RelationshipsRelationships

1- Association

Multiplicity:

Page 30: April 2006

30Unified Modeling Language

RelationshipsRelationships

1- Association

Aggregation: A Special Kind of Association

تعريف:- Aggregation: whole/part relationships, Instances on one side are

aggregates (or wholes) and the instances on the other side are their parts.- An association that models HAS-A relationships- The objects can exist independently or each other- No one object is more important than the other- An Aggregation relationship may be called isPartOf or consistsOF.

School Student0..*1

Page 31: April 2006

31Unified Modeling Language

RelationshipsRelationships

1- Association

Composition: A Special Kind of Association

تعريف:- Composition: Strangle relationship, If the parts in the part-whole

relationship are non-shareable.- One can not exist without the other- Composition is a anti-symmetric and transitive relation.- In aggregation relationship, the part may be included in several

aggregates and its owner may also change over time.

School Department1 1..*

Page 32: April 2006

32Unified Modeling Language

RelationshipsRelationships

1- Association

Examples for aggregation and composition relationships:

Page 33: April 2006

33Unified Modeling Language

RelationshipsRelationships

2- Dependency

ممکن Bتعريف: رابطه استفاده کالسي از کالس ديگر. تغيير در کالس

تاثير بگذارد.Aاست بر روي کالس

- occurs when one object depends on another- if you change one object's interface, you need to change the

dependent objectDirected is optional and label is optional.

Page 34: April 2006

34Unified Modeling Language

RelationshipsRelationships

3- Generalization

. در کالس ها معني توارث مي دهد، اما براي بقيه اجزاء نيز is-aتعريف: رابطه تعميم يا رابطه

مي تواند استفاده شود.

- Objects of the Specialized element (the child) are substitutable for objects of the generalized element (the parent).

- The child shares the structure and the behavior of the parent. Child class is a special case of the

parent class

Page 35: April 2006

35Unified Modeling Language

RelationshipsRelationships

4- Realization

تعريف: رابطه تحقق يا عينيت بخشيدن. يکي از طرفين وظيفه پياده سازي طرف ديگرا

را به عهده دارد. يک سمت، يک چيز واقعي و سمت ديگر چيز فرضي است.a semantic relationship between two elements, wherein one element

guarantees to carry out what is expected by the other element. Where? Between interfaces and classes that realize them… Between use cases and the collaborations that realize

them...

Page 36: April 2006

36Unified Modeling Language

DiagramsDiagrams : :Use CaseUse Case تعريف: دياگرام مورد کاربرد بصورت گرافيکي رفتار سيستم را از منظر بيروني سيستم نشان مي دهد و بخشي يا تمام موارد کاربرد سيستم را

نشان مي دهد.

هدف: آناليز نيازمنديهاي سيستم براي اينکه نشان دهد سيستم چه کار ميکند البته توالي کار را نمايش نمي دهد.

يک دياگرام مورد کاربرد عناصر زير را نشان مي دهد.

1 -Actor.فرد، سيستم، خردسيستم، يا سخت افزاري که در سيستم نقش دارند. عملي را انجام داده يا نتيجه اي را دريافت ميکنند :

2 -Use Case مجموعه عملياتي که توسط :Actor انجام ميشود تا نتيجه اي معيني را توليد کرده يا در اختيار Actor.قرار دهد

What not How- تعيين ”چه“ و عدم توجه به ”چگونگي“

ها را نمايش ميدهد.Use Case فهرست امکانات سيستم، فهرست -

کشيده ميشود.Use Case View- دياگرام مورد کاربرد در

- دياگرام مورد کاربرد جزو دياگرام هايي است که

جنبه ديناميکي سيستم را نشان ميدهد.

Page 37: April 2006

37Unified Modeling Language

DiagramsDiagrams : :Use CaseUse Case

:مراحل رسم نمودار مورد کاربرد

بصورت کلي در براي رسم نمودارهاي مورد کاربرد سيستم بايد سه مورد را انجام داد:

A ها و ارتباط آنها -تعيين ارتباط Use Case ها و ارتباط آنها -شناسايي Actor-شناسايي

ctor ها و Use Caseها

وظايف:

مثال: سيستم فروش: مشتري، فروشنده، مدير فروش، سيستم : هاActor- شناسايي 1

سيستم و ...Adminحسابداري،

ها:Actor- سازماندهي 2

)Packaging(- گروه بندي

در صورت لزومGeneralization- استفاده از رابطه

Stereotype- استفاده از

Page 38: April 2006

38Unified Modeling Language

DiagramsDiagrams : :Use CaseUse Case

:وظايف

ها Use Case --- < فهرست : هاActor- شناسايي عمليات هر يک از 3

Page 39: April 2006

39Unified Modeling Language

DiagramsDiagrams : :Use CaseUse Case

:وظايف

ها: Use Case- سازماندهي 4

Packageالف- استفاده از

Stereotypeب- استفاده از

Generalizationج-استفاده از

Page 40: April 2006

40Unified Modeling Language

DiagramsDiagrams : :Use CaseUse Case

:وظايف

Association ها: فقط رابطه Use case ها و Actor- شناسايي ارتباط بين 5

در نمودار مورد کاربرد مي تواند دو طرفه باشد:Associationرابطه

- Actor کاري انجام ميدهد. - نتيجه کار انجام شده در اختيار Actor .قرار مي گيرد

Page 41: April 2006

41Unified Modeling Language

DiagramsDiagrams : :Use CaseUse Case

:وظايف

Dependency ها با کمک رابطه Use case - شناسايي ارتباط 6

بين آنها برقرار است. Dependencyوقتي يک مورد کاربرد از ديگري استفاده مي کند، رابطه

جهت رابطه مهم است.

معروف استفاده ميشود: Stereotypeدر اين حالت دو

1 -<<include>> عمليات :Bحين انجام عمليات A.انجام ميشود

2 -<<Extend>> عمليات :B بصورت احتمالي

انجام ميشود. A(انتخاب کاربر، شرايط موجود و ...) پس از اجراي عمليات

Page 42: April 2006

42Unified Modeling Language

DiagramsDiagrams : :Use CaseUse Case

يک مثال براي کليه روابط ممکن در نمودار مورد کاربرد :

Page 43: April 2006

43Unified Modeling Language

DiagramsDiagrams : :Activity DiagramActivity Diagram

تعريف: An Activity diagram shows the flow from activity to activity.An Activity is an ongoing nonatomic execution with in state machine.Activity result in some actions

با استفاده از نمودار فعاليت ميتوان جريانهاي کاري را درسطوح مختلفي از .سيستم مدل کرد

.جريان کاري در فرايند کل سيستم -جريان کاري در فرآيند زير سيستم ها -

جريان کاري در سطح موارد کاربرد (سناريوها) -جريان کاري در سطح کالس ( يک متد از کالس) -

.جنبه ديناميکي سيستم را مدل مي کند و اساسا مانند فلوچارت ميباشد -براي مدل کردن جريانهاي کاري در سطح سيستم يا زيرسيستم ها بهتر است از -

.نام موارد کاربرد براي نام فعاليتها استفاده کرد

با هم معادل هستند و هر دو حالت خاص از Statechart و Activity Diagram- نمودارهاي State Machine.ها هستند

-Activity Diagram: Activity Centric Statechart: State Centric

-Statechart براي مدل کردن رفتار Object.در طول حيات آن استفاده ميشود

Page 44: April 2006

44Unified Modeling Language

DiagramsDiagrams : : Activity DiagramActivity Diagram

Elements:

1 -Activity State يک فعاليت طوالني و قابل اينتراپت که ممکن خردفعاليتهاي ديگري :

داشته باشد.

2 -Action State .يک فعاليت کوتاه که حالت اتميک دارد :

Pure Computation يا Method Callمانند يک

هاي مربوطه را مشخص کرد.Action ها، State ميتوان درون Rational Roseدر

استفاده ميشود.Activity از نام Activity State بجاي RRضمنا در

­Activity: represents the performance of task or duty in a workflow.

State: represents a condition or situation during the life of an object

during which it satisfies some condition or waits for some event.

Page 45: April 2006

45Unified Modeling Language

DiagramsDiagrams : : Activity DiagramActivity Diagram

Elements:

تعريف کرد که در حاالت زير اتفاق Action ها ميتوان State ها يا Activity درون هريک از RRدر

مي افتند.· on entry: the task must be performed when the object enters the state or activity· on exit: the task must be performed when the object exits the state or activity· do: the task must be performed while in the state or activity until existing· on event: the task triggers an action only if a specific event is received.

3 -Start/End State:

- حالت شروع فقط يکي

عدد n تا 0- حالت پايان

Page 46: April 2006

46Unified Modeling Language

DiagramsDiagrams : : Activity DiagramActivity Diagram

Elements:

4 -Transition.انتقال از فعاليت يا حالتي به فعاليت يا حالت ديگر :

دو نوع دارد:

-Trigger less با اتمام عمل (فعاليت) قبلی، عمل بعدي :

Activity به Activityشروع ميشود. بيشتر براي انتقال از

-Guarded با کنترل شرط عمل بعدي آغاز ميشود. بيشتر براي انتقال از يک :State

4 -Branch Decision: زماني استفاده ميشود که مسير

Transition بنابر حاالت مختلف )Guard Conditions(

گذاشته مي شود نه برTransition فرق کند. پس شرط بر روي

.Decision روي

Page 47: April 2006

47Unified Modeling Language

DiagramsDiagrams : : Activity DiagramActivity Diagram

Elements:

4 -Fork & Join (Synchronization):

: تقسيم کنترل يک جريان کاري به دو يا چند جريان کاري همزمان. (شروع عمليات Forkتعريف

همزمان)

: يکي کردن دو يا چند جريان کاري به يک جريان کاري. (خاتمه همه عمليات هاي همزمان)Joinتعريف

انجام مي دهيم.Synchronization اين دو را با استفاده از RRدر

که داراي دو نوع افقي و عمودي است.

هاي مختلف صورت بگيرد.Swimlane- بايد در

ها بايد متوازن باشند.Join ها و Fork- تعداد

-Activityهاي موازي الزاما مستقل نيستند و

احتمال عمليات همزمان وجود دارد که اصطالحا آنها را

Co-Routine مي گويند. ميتوان با Object Flow.آنها را نشان داد

Page 48: April 2006

48Unified Modeling Language

DiagramsDiagrams : : Activity DiagramActivity Diagram

Elements:

5 -Swimlane:

تعريف: براي جداسازي و تفکيک وظايف استفاده ميشود.

براي تفکيک وظايفBusiness- معموال در مدلسازي

و مسئوليتها در جريان هاي کاري استفاده ميشود.

، يک کالس،Actor ميتواند نام يک Swimlane- هر

، نقش يک کالس، زيرسيستم ها، واحدهاي Objectيک

ومختلف سازمان و ... باشد که نشان ميدهد آن فعاليت را

چه کسي انجام ميدهد.

ظاهر نميشود. Statechart- در

- بخش هاي مختلف سازمان کانديداهاي خوبي برای

Swimlane(وظايف هر بخش و ارتباط بخش ها را نشان ميدهد) .ها هستند

Page 49: April 2006

49Unified Modeling Language

DiagramsDiagrams : : Activity DiagramActivity Diagram

Activity Diagram

Use Case Sample :

Page 50: April 2006

50Unified Modeling Language

DiagramsDiagrams : : Class DiagramClass Diagram

Definition: A class diagram is a diagram that shows a set of classes, and collaborations and their relationships

-Class diagrams contain classes and object diagrams contain objects

-Class diagrams are more prevalent than object diagrams. Normally you will build class diagrams plus occasio

nal object diagrams illustrating complicated data structures

سيستم را Static ميباشد و جنبه Structural Modeling تهيه ميشود. جزو Logical view- عمدتا در قسمت

مدل ميکند.

هاي منطقي Package توصيه ميشود که دياگرام کالس در سطح کل سيستم و نيز در سطح RR- در

تهيه شود.

Use Class Diagrams To:Analysis: Show common roles and responsibilities of the entities that provide the system's

behavior.

Design: Capture the structure of the classes that form the system's architecture.

Page 51: April 2006

51Unified Modeling Language

DiagramsDiagrams : : Class DiagramClass Diagram

- معموال براي طراحي شيءگرا از چند اليه نرم افزاري برای ساخت سيستم استفاده ميشود که

بندي کالسها باشد. بطور مثال دياگرام کالس زير روابط بين Packageميتواند مبنايي براي

اين اليه ها را نشان ميدهد:

-Class Diagram:معموال عناصر زير را در بر دارد

1 -Class 2- Interface 3- Collaboration 4- Dependency, Generalization and Association

- جنبه رفتاري کالسها (اشياء) با استفاده از دياگرامهاي زير صورت ميگيرد:

1 -Interaction Diagram (Sequence or Collaboration Diagram)

2 -Statechart Diagram 3- Activity Diagram

Page 52: April 2006

52Unified Modeling Language

DiagramsDiagrams : : Class DiagramClass Diagram

اسم يا جمله اسميه- نام گذاري:

، ...User Data Type، Enumeration فرد، مکان، رويداد، شيء فيزيکي، مفاهيم، - انواع کالس:

ها مشخص کرد.Stereotypeاين موارد را ميتوان با

Page 53: April 2006

53Unified Modeling Language

DiagramsDiagrams : : Class DiagramClass DiagramVisibility: Specify whether attribute or Operation cab be used by another classes.

1- Public: members of a class are accessible to all clients. This is the default access.

2- Protected: members of a class are accessible only to subclasses, friends, or to the class itself.

3- Private: members of a class are accessible only to the class itself or to its friends.

4- Friend (Implemented in RR): the class is accessible only by the implementation of the package containing the class.

Page 54: April 2006

54Unified Modeling Language

DiagramsDiagrams : : Class DiagramClass DiagramMultiplicity:

نشان دهنده آن است که در يک لحظه حداکثر چند نمونه از آن کالس ميتوانند وجود داشته .باشند

- Syntax: min .. max- Cases: بيشتر کالسهاي ورود اطالعات از اين دسته هستند 1 .. 0 1 .. 1 example: main form

0 .. 0 فرق دارد.Abstract (No Instance)با حالت باشد (توابع محاسباتي و رشته اي) Class Scope هايش Operationمانند کالسي که تمام که

گويند.Utility Class به آنها Dim m as math s = m.sin(90)

نيز استفاده ميشود.N و N ، 1 .. N .. 0حالت هاي

Attributes:- Syntax: [visibility] name [multiplicity] [:type] [= initial value] [{property}]

مانند کالس است.Visibility- خاصيت نداريم.RR به معني آرايه بودن است که در Multiplicity- خاصيت را داشته باشد.Addonly و Changable، Frozen ميتواند يکي از مقادير Property- خاصيت

Page 55: April 2006

55Unified Modeling Language

DiagramsDiagrams : : Class DiagramClass DiagramProperty Cases:

.هر ويژگي ميتواند يکي از حاالت زير را داشته باشد -- Changeable (default): Read / Write- Frozen: Write Once

.فقط يکبار ميتوان به آن مقدار داد و بعد از آن قابل تغيير نيستConst ، Auto number مانند:

- AddOnly: معنا دارد.Multiplicity < 1براي

فقط اضافه ميشوند و مقادير قبلي حفظ ميشوند. مانند: حکم کارمندي

Operations:- Syntax: [visibility] name [(in|out|inout) parameter name: type = default value, . . .)] [: return type] [{property}]Example: ConvertToGerog (PerDate: String = CurDate): Date

مانند کالس است.Visibility- خاصيت

Page 56: April 2006

56Unified Modeling Language

DiagramsDiagrams : : Class DiagramClass Diagram

Generalization Relationship: A generalization is a relationship between a general thing (called the superclass or parent) and a m

ore specific kind of that thing (called the subclass or child)

Stereotypes:1- implementation: child inherits the implementation of the parent but does not make public nor support its interfacesConstraints:1- Complete: all children in the generalization have been specified in the model2- incomplete: all children in the generalization haven’t been specified in the model

Page 57: April 2006

57Unified Modeling Language

DiagramsDiagrams : : Class DiagramClass Diagram

Association Relationship: A association is a structural relationship, specifying that objects of one thing

are connected to objects of another.

- Navigation:Possibility to navigate from objects of one kind to objects of other kind.

- Visibility: indicated in role name. 1- Public: objects at the end are accessible to any objects outside the

association 2- Private: objects at the end are not accessible to any objects outside the

association 3- Protected: objects at the end are not accessible to any objects outside the

association, except for children of the other end

Page 58: April 2006

58Unified Modeling Language

DiagramsDiagrams : : Class DiagramClass Diagram

Association Relationship:- Qualification:By given an object of workDesk an given a particular value of JobID, can navigate to zero or one object

of ReturnedItem.

- Composition and Aggregation:

School Student0..*1

School Department1 1..*

Page 59: April 2006

59Unified Modeling Language

DiagramsDiagrams : : Class DiagramClass Diagram

Realization Relationship: A realization is a semantic relationship between classifiers in which one

classifier specifies a contract that another classifier guarantees to carry out.

Page 60: April 2006

60Unified Modeling Language

DiagramsDiagrams : : Class DiagramClass Diagram

Example:

Page 61: April 2006

61Unified Modeling Language

DiagramsDiagrams : :Object DiagramObject Diagram

تعريف: An Instance is a concrete manifestation of an abstraction to which a set of operation can

be applied and which has a state stores the effects of operations.

An Object is a instance of a class: concrete manifestation of a class

- An object is something that takes up space in the real or conceptual world

را در نظر گرفت.Instanceبراي عناصر زير نيز ميتوان مفهوم -Usecase - Node - Association - Component

- When you model instances, you’ll place them in 1- Object Diagram (visualize their structural details) 2- Interaction and activity diagrams (visualize their participation in dynamic situations) 3- Class diagram (show the relationship of an object to its abstraction)

- The classifier of an instance is usually static

Page 62: April 2006

62Unified Modeling Language

DiagramsDiagrams : :Object DiagramObject Diagram Object Name: every instance must have a name that distinguish it from other instances wit

hin its context.

Object Operation: is declared in object’s abstractionSyntax: className.OperationName() ex.: trans.Commit()

Page 63: April 2006

63Unified Modeling Language

DiagramsDiagrams : :Object DiagramObject Diagram

Object State: is all the properties of the object (usually static) + the current values of each these properties (usually dynam

ic)

Page 64: April 2006

64Unified Modeling Language

DiagramsDiagrams : :Object DiagramObject Diagram

تعريف: An object diagram is a diagram that shows a set of objects and their relationships at a poi

nt in time (for model object structures)

- An object diagram shows the existence of objects and their relationships in the logical design of a system

- An object diagram is essentially an instance of a class diagram or static part of an interaction diagram

To model an object structure:

1- Identify the mechanism: A mechanism represents some function or behavior of the part of the syste

m that results from the interaction of a society of classes, interfaces …

2- For each mechanism, identify the classes, interfaces, … and their relationships.

3- Use scenario to walk through these things. Freeze that scenario at a moment in time and render eac

h object that participates in the mechanism.

4- Expose the state and attribute value of each object.

5- Expose the links among these objects (instances of associations)

Page 65: April 2006

65Unified Modeling Language

DiagramsDiagrams : :Object DiagramObject Diagram Object Diagram Example1:

ها براي Note و Message بدون Collaboration Diagram نداريم. ميتوان از RR ، Object Diagramدر اين منظور استفاده کرد.

Page 66: April 2006

66Unified Modeling Language

DiagramsDiagrams : :Object DiagramObject Diagram Object Diagram Example2:

Page 67: April 2006

67Unified Modeling Language

DiagramsDiagrams : :Interaction DiagramInteraction Diagram

تعريف: An Interaction is a behavior that comprise a set of messages exchanged among a set of o

bjects within a context to accomplish a purpose.

A Message is a specification of a communication between objects that conveys information with the expectation that activity will ensue.

-Interaction Diagrams: 1- Sequence diagram تاکيد بر روي توالي 2- Collaboration diagram (ساختار ارتباط) تاکيد بر نحوه ارتباط

- Context: 1- Collaboration 2- Operation 3- Class

- Objects and Roles: 1- Concrete object 2- Prototypical object

منظور Abstract يک کالس objectنکته: در صورت استفاده از هاي کالسهاي مشتق شده است.Objectتمام

Page 68: April 2006

68Unified Modeling Language

DiagramsDiagrams : : Interaction DiagramInteraction Diagram

-Link:A Link is a semantic connection among object.an instance of an association or one object send a message to the another.Visibility Stereotypes:1- Association: object is visible by association2- Self: object is visible because it is the dispatcher of the operation.3- Global: object is visible because it is in an enclosing scope.4- Local: object is visible because it is a local scope.5- Parameter: object is visible because it is a parameter.

-Message:A Message is a specification of a communication between objects that conveys informatio

n with the expectation that activity will ensue.Message -< Action -< Change StateKinds of Actions:1- Call: invokes an operation on an object2- Return: returns a value to the caller3- Send: send a signal to an object (Asynchronous call)4- Create: creates an object5- Destroy: destroys an object

Page 69: April 2006

69Unified Modeling Language

DiagramsDiagrams : : Interaction DiagramInteraction Diagram

-Message Sequencing:Can explicitly model the order of the messages by prefixing each messages with a sequen

ce number set apart by a colon separator.

-Flow of Control:1- Nested or Procedural شماره بصورت سلسله مراتبي پيش ميرود2- Flat شماره بصورت سريال پيش ميرود

Page 70: April 2006

70Unified Modeling Language

DiagramsDiagrams : : Interaction DiagramInteraction Diagram

- Object Lifetime:To specify if an object or link enters and/or leaves during an interactionConstraints:1- New: instance is created during execution of enclosing interaction2- Destroyed: instance is destroyed prior to completion of execution of enclosing interactio

n3- Transient: is created during execution of enclosing interaction but is destroyed before c

ompletion of execution

Modeling Flow of Control:The most common purpose of interaction diagrams is modeling the flow of control that cha

racterizes the behavior of system, class or an individual operation.To model a flow of control:1- set the context for the interaction2- identifying which objects play a role. determine their initial attributes values, states and

roles.3- identifying the links and messages that connect them. Identifying stereotyps, constrain

ts, parameters and return values4-convey the necessary detail of the interaction.

Page 71: April 2006

71Unified Modeling Language

DiagramsDiagrams : : Interaction DiagramInteraction Diagram Kinds of Modeling Flow of Control:1- by time: emphasize the time order of messages sequence diagram2- by organization: emphasize the structural organization of the

objects collaboration diagram

Page 72: April 2006

72Unified Modeling Language

DiagramsDiagrams : :Interaction DiagramInteraction Diagram

تعريف: An Interaction diagram shows an interaction, consisting of a set of objects and their relatio

nships, including the messages that may be dispatched among them.

-Interaction Diagrams: 1- Sequence diagram تاکيد بر روي توالي 2- Collaboration diagram (ساختار ارتباط) تاکيد بر نحوه ارتباط

- Contents: 1- Objects 2- Links امکان تبادل اطالعات 3- Messages

Page 73: April 2006

73Unified Modeling Language

DiagramsDiagrams : :Interaction DiagramInteraction Diagram

تعريف: A Sequence diagram is an interaction diagram that emphasize the time ordering of messa

gesAppropriate features:1- object lifetime: represents the existence of object over a period of time2- focus of control: shows the period of time during which an object is performing an actio

n

X: ObjectsY: Time

Page 74: April 2006

74Unified Modeling Language

DiagramsDiagrams : :Interaction DiagramInteraction Diagram

تعريف: An Collaboration diagram is an interaction diagram that emphasize the structural organizati

on of the objects.

Appropriate features:1- sequence number: to indicate the time order of a message2- path and path streotype

More complex flows:1- iteration: by prefixing the sequencenumber with expressionsuch as [i:=1..n]2- branch: by prefixing the sequence number with condition clause such as [x<0]

Page 75: April 2006

75Unified Modeling Language

DiagramsDiagrams : :Interaction DiagramInteraction Diagram Modeling Techniques: 1- Modeling Flow of Control by Time Ordering

Page 76: April 2006

76Unified Modeling Language

DiagramsDiagrams : :Interaction DiagramInteraction Diagram Modeling Techniques: 1- Modeling Flow of Control Organization

Page 77: April 2006

77Unified Modeling Language

DiagramsDiagrams : :Statechart DiagramStatechart Diagram

State machine:

تعريف:

A state machine is a behavior that specifies the sequence of states an object goes through during its lifetime in response to events, together with its responses to those events.

A state is a condition or situation during the life of an object during which it satisfies some condition, performs some activity or waits for some event.

An event is the specification of a significant occurrence that has a location in time and space. (trigger a state transition)

A transition is a relationship between two sates indicating that an object in the will perform certain actions and enter the second state when a specified event occurs and specified condition are satisfied.

An activity is ongoing nonatomic execution within a state machine.

An action is an executable atomic computation that results in a change in state of the model or the return of a value.

-state machine جنبه ديناميکي سيستم (رفتاري) را مدل ميکند و برخالف interaction يک ، Object.خاص را مدل ميکند

Page 78: April 2006

78Unified Modeling Language

DiagramsDiagrams : :Statechart DiagramStatechart Diagram

-state machine معموال زمان حيات يک Object را مدل ميکند که ميتواند instance از يک کالس، مورد کاربرد يا کل سيستم باشد.

State machine can be visualized in two ways:1 -Activity diagram: focus on the activities that take place within the object.

2 -Statechart diagram: focus on the event-ordered behavior of an object.

Page 79: April 2006

79Unified Modeling Language

DiagramsDiagrams : :Statechart DiagramStatechart Diagram

A state is a condition or situation during the life of an object during which it satisfies some condition, performs some activity or waits for some event.

A state is a several parts:1-name2-entry/exit action3-internal transition: are handled without causing a change in state4-substates: nested structure of a state involving 1-disjoint (sequentially active) or 2-concurrent

substates5-deffered events: a list of events that are not handled in that state

but, rather, are postponed and queued for handling by the object in another state.

Page 80: April 2006

80Unified Modeling Language

DiagramsDiagrams : :Statechart DiagramStatechart Diagram

A transition is a relationship between two sates indicating that an object in the will perform certain actions and enter the second state when a specified event occurs and specified condition are satisfied.

-transition ميتواند چندين مبدا و چندين مقصد داشته باشد. در state هاي موازي )join & fork(معنا دارد.

A transition has five parts:1-source state2-event trigger3-guard condition4-action5-target state

يکبار guard condition بصورت مرتب و پيوسته چک ميشود ولي event اتفاق افتادن - ارزيابي ميشود.eventو آنهم بعد از روي دادن

Page 81: April 2006

81Unified Modeling Language

DiagramsDiagrams : :Statechart DiagramStatechart Diagram

substates:A state that has substates that is, nested states is called composite

state.A composite state may contain either concurrent or sequential

substates.

1-sequential substates:After dispatching entry action (if any), control passes to the nested

state and dispatching its entry action (if any) and reverse on exit.

Page 82: April 2006

82Unified Modeling Language

DiagramsDiagrams : :Statechart DiagramStatechart Diagram

The most common purpose

for use state machine:

Modeling the lifetime

of an object

Page 83: April 2006

83Unified Modeling Language

DiagramsDiagrams : :Statechart DiagramStatechart Diagram

Statechart Diagram:

تعريف:A Statechart diagram shows a state machine, emphasizing the flow of control from state t

o state.

- Statechart is one of five diagrams to modeling dynamic aspects of system.

- Activity diagram is a special case of a statechart diagram in which all or most of the states are activity states and all or most of the transitions are triggered by completion of activities in the source state.

- Both activity and statechart are useful in modeling the lifetime of an object. activity diagram: shows flow of control from activity to activity statechart diagram: shows flow of control from state to state.

- Statechart diagrams commonly contain: 1- simple and composite states 2- transactions, including events and actions

Page 84: April 2006

84Unified Modeling Language

DiagramsDiagrams : :Statechart DiagramStatechart Diagram

Statechart diagram example:

Page 85: April 2006

85Unified Modeling Language

DiagramsDiagrams : :Component DiagramComponent Diagram

تعريف:A component is a physical and replaceable part of a system that conforms to and provides

the realization of a set of interfaces

- name: 1-simple name 2-path name

Page 86: April 2006

86Unified Modeling Language

DiagramsDiagrams : :Component DiagramComponent Diagram

components and classes:Similarities:1-both may realize a set of interfaces2-both may participate in dependency, generalization and association relationship3-both may be nested4-both may have instances5-both may be participants in interactions

Difference:classes represent logical abstraction; component represent physical thing.components may live on nodes, classes may not.

Page 87: April 2006

87Unified Modeling Language

DiagramsDiagrams : :Component DiagramComponent Diagram

Binary replaceability:- A component is substitutable. Support previous interfaces and provide new services thro

ugh other services.Goal: create a system out of components and then evolve that system by adding new com

ponent and replacing old ones, without rebuilding the system.

Kind of components:1- deployment components: necessary and sufficient to form an executable system, such

as DLLs and EXEs.2- work product components: are essentially the residue of the development process, con

sisting of things such as source code files and data files.3- execution components: are created as a consequence of an executing system. Such as

a COM+ object, which is instantiated from a DLL.

Components stereotypes:1- executable: a component that may be executed on a node2- library: a static or dynamic object library3- table: a component that represents a database table4- file: a component that represents a document containing source code or data5- document: a component that represents a document

Page 88: April 2006

88Unified Modeling Language

DiagramsDiagrams : :Component DiagramComponent Diagram

تعريف:A component diagram shows a set of components and their relationships.- Modeling the physical aspect of OO systems - Shows the organization and dependencies among a set of components.

Contents: 1-components 2-interfaces 3-realationships

Page 89: April 2006

89Unified Modeling Language

DiagramsDiagrams : :Deployment DiagramDeployment Diagram

تعريف:A node is a physical element that exists and represents a computational resource, general

ly having at least some memory and often, processing capability.

- name: 1-simple name 2-path name

Page 90: April 2006

90Unified Modeling Language

DiagramsDiagrams : :Deployment DiagramDeployment Diagram

nodes and components:Similarities:2-both may participate in dependency, generalization and association relationship3-both may be nested4-both may have instances5-both may be participants in interactions

Difference:- Components are things that participate In execution of a system; nodes are Things that execute components- Components represent the physical packaging of otherwise logical elements; nodes represent the physical deployment of components

Page 91: April 2006

91Unified Modeling Language

DiagramsDiagrams : :Deployment DiagramDeployment Diagram

Connections:The most common kind of relationship between nodes is an association.

Page 92: April 2006

92Unified Modeling Language

DiagramsDiagrams : :Deployment DiagramDeployment Diagram

تعريف:A deployment diagram is a diagram that shows the configuration of run time processing no

des and the components that live on them.

Contents: 1-nodes 2-relationships - dependency - association

Page 93: April 2006

93Unified Modeling Language

UML Extension MechanismUML Extension Mechanism

Lightweight Extension Mechanism

Heavyweight Extension Mechanism

Page 94: April 2006

94Unified Modeling Language

Lightweight Extension MechanismLightweight Extension Mechanism

Constraints

Tagged Values

Stereotypes

Page 95: April 2006

95Unified Modeling Language

Constraints (OMG Description)Constraints (OMG Description)

Page 96: April 2006

96Unified Modeling Language

ConstraintsConstraints

Page 97: April 2006

97Unified Modeling Language

Tagged Values (OMG Description)Tagged Values (OMG Description)

Page 98: April 2006

98Unified Modeling Language

Tagged ValuesTagged Values

Page 99: April 2006

99Unified Modeling Language

Stereotypes (OMG Description)Stereotypes (OMG Description)

Page 100: April 2006

100Unified Modeling Language

Stereotypes Stereotypes

Decorative

Descriptive

Restrictive

Redefined

Evolutionary

Page 101: April 2006

101Unified Modeling Language

Stereotypes Stereotypes

Page 102: April 2006

102Unified Modeling Language

in Conclusionin Conclusion

:UMLموضوعات پيشنهادي براي ادامه مباحث UML- مدلسازي منطقي و فيزيکي با استفاده از 1UML- طراحي سيستمهاي بالدرنگ با استفاده از 2Multithread- طراحي سيستمهاي 34 -Design patternsRUP در توليد نرم افزار با متدولوزي UML- بکارگيري 5

End