Vous êtes sur la page 1sur 34

Things and Relationships In Detail

Conceptual Model of UML


Things Structural things Behavioral things Grouping things Annotation things

Structural Things
Nouns of UML models Examples: Class Interface Collaboration Use case Components Artifacts Node

Structural Modeling: Core Elements


Construct Description
a description of a set of objects that share the same attributes, operations, methods, relationships and semantics. a named set of operations that interface characterize the behavior of an element. component a modular, replaceable and significant part of a system that packages implementation and exposes a set of interfaces. a run-time physical object that node represents a computational resource. class

Syntax

interface

Structural Modeling: Core Elements (contd)


Construct Description
constraint a semantic condition or restriction.
{constraint}

Syntax

An extension mechanism useful for specifying structural elements.

Class
Description of a set of objects that share the same attributes, operations, relationships and semantics. Note that the operations open( ), close( ), etc. are behavioral things, so a class can also be a grouping thing
Window {abstract, author=Joe, status=tested} +size: Area = (100,100) #visibility: Boolean = true +default-size: Rectangle #maximum-size: Rectangle -xptr: XWindow* +display () +hide () +create () -attachXWindow(xwin:Xwindow*)

Window

Window size: Area visibility: Boolean display () hide ()

Interface

Collection of operations that specify a service of a class or component Describes the externally visible behavior of a component Usually attached to a class or other component

Interfaces: Shorthand Notation

StoreHome POSterminalHome POSterminal POSterminal Store <<use>>

Store -storeId: Integer -POSlist: List +create() +login(UserName, Passwd) +find(StoreId) +getPOStotals(POSid) +updateStoreTotals(Id,Sales) +get(Item)

Interfaces: Longhand Notation

StoreHome POSterminalHome POSterminal <<use>> POSterminal <<interface>> Store +getPOStotals(POSid) +updateStoreTotals(Id,Sales) +get(Item)

Store -storeId: Integer -POSlist: List +create() +login(UserName, Passwd) +find(StoreId) +getPOStotals(POSid) +updateStoreTotals(Id,Sales) +get(Item)

Collaboration

A society of roles and other elements that work together to provide a collective behavior Has structural and behavioral elements enclosed in it

Components & Nodes

Component
Modular part of system design that hides its implementation behind set of external interfaces A physical packaging of otherwise logical elements (i.e., accessible through the interfaces)

Node

Physical element that exists at runtime and represents a computational resource having some memory and processing ability

Conceptual Model of UML


Building blocks of the UML Things

First class citizens Tie things together Group interesting collections of things

Relationships Diagrams

Things Structural things Behavioral things Grouping things Annotation things

Behavioral Things
Dynamic part of UML models Verbs of model, representing behavior over time and space Generally connected to classes, collaborations & objects. 3 kinds: Interaction State Machine Actions

Interaction
Set of messages exchanged among objects within a context to accomplish a purpose. An interaction includes messages, action sequences(behavior invoked by a message) and links (relationships between objects) Points to object that receives the messages

display

Example
Message is called show Sent from button to window In real world, a button object sends a show message to a window object.

State machine
Sequence of states an object or interaction goes through, along with events to which it responds and its responses to those events Includes states, transitions (flow from state to state), events (things that trigger a transition), activities (response to a transition). State is shown as a rounded rectangle
caller off hook Idle Caller Active

Caller on hook

Conceptual Model of UML


Building blocks of the UML Things

First class citizens Tie things together Group interesting collections of things

Relationships Diagrams

Things Structural things Behavioral things Grouping things Annotation things

Grouping Things
Things into which you can decompose a model, or with which you can combine model elements. Packages Structural things, behavioral things, and/or grouping things can be placed in a package. Shown as a "tabbed" folder:

Annotational Things
Comments to describe, illuminate or remark about any element in a model. Note Used for informal or formal text Used for specifying some aspect outside the model

This is a note which acts like a comment!

Conceptual Model of UML


Building blocks of the UML Things

First class citizens Tie things together Group interesting collections of things

Relationships Diagrams

Structural Modeling: Core Relationships


Construct
association

Description

Syntax

a relationship between two or more classifiers that involves connections among their instances. A special form of association that aggregation specifies a whole-part relationship between the aggregate (whole) and the component part. generalization a taxonomic relationship between a more general and a more specific element. a relationship between two modeling dependency elements, in which a change to one modeling element (the independent element) will affect the other modeling element (the dependent element).
20

Structural Modeling: Core Relationships (contd)


Construct
realization

Description
a relationship between a specification and its implementation.

Syntax

21

Relationships
Dependency Relationship between two things where a change in one thing (the "independent" thing) may affect the meaning of another thing (the "dependent" thing) Alternatively dependent thing uses independent thing Arrow goes from the "dependent" thing to the "independent" thing. Example: Window depends on Event Window uses Event

Association
Structural relationship that describes a set of links; i.e., relationships between objects. May have direction, may include a label, and often containing adornments such as multiplicity and role names: Example:

Generalization
Specialization/generalization relationship in which objects of the specialized element ("child") are substitutable for objects of the generalized element ("parent"). Child shares structure and behavior of parent Example: Employee is a kind of Person

Realization
One element specifies a "contract" that another element must carry out. Open-headed arrow points from the realizer to the element with the contract The element carrying out the contract is said to realize the other element. Example:

Aggregation
Construct aggregation Description A special form of association that specifies a whole-part relationship between the aggregate (whole) and the component part. Syntax

A composite aggregation (filled diamond) means that the multiplicity at the composite (part) end may be at most one. Shared aggregation (hollow diamond) means that the multiplicity at the composite end may be more than one.

26

Aggregation
Aggregation is the part-whole relationship. It relates classes, representing parts (or components) to the whole (or assembly) class.

27

UML Aggregation
In UML there are three types of aggregation:

Normal Aggregation Shared Aggregation Composition aggregation

28

Composition Aggregation
The whole owns the instances of the parts. Those instances cannot belong to any other instance of the whole.

Composition Aggregation forms a tree structure.


The lifetime of the whole dictates the lifetime of the constituent parts.

29

Composition Aggregation Example

Aircraft

1+

Engine

Wing

Fuselage

2+ Door Landing Gear

30

Composition
Window scrollbar [2]: Slider title: Header body: Panel

Window 1 scrollbar Slider 2 1 1 title

1 Header

body

1 Panel

31

Composition (contd)

Window

scrollbar:Slider

1 title:Header 1 body:Panel

32

Aggregation

Aggregation is most useful when there are common properties of components that can be attached to the assembly as a whole Or where operations can propagate from container to contained objects

Parts explosions are the most compelling examples of aggregation

33

Vous aimerez peut-être aussi