Top Banner
Link and Association Concepts
21

class ppt_3.pptx

Dec 21, 2015

Download

Documents

Apoorva Naik
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: class ppt_3.pptx

Link and Association Concepts

Page 2: class ppt_3.pptx

• A link is a physical or conceptual connection among objects

• Most links relate two objects, but some links relate three or more objects

Page 3: class ppt_3.pptx

John: Person

name = “John”

Mary: Person

name = “Mary”

Sue: Person

name = “Sue”

Alice: Person

name = “Alice”

GE: Company

name = “GE”

IBM: Company

name = “IBM”

Object diagram

John and Mary own stock in GE company. Mary and Sue own stock in IBM company. Alice does not own stock in any company and thus has no link

Page 4: class ppt_3.pptx

• An association is a description of a group of links with common structure and common semantics.

• The links of an association connect objects from the same classes.

• An association describes a set of potential links in the same way that a class describes a set of potential objects

Page 5: class ppt_3.pptx

Person

name

Company

name

OwnsStock

* *

Class diagram

A person may own stock in zero or more companies; a company may have multiple persons owing its stock

Page 6: class ppt_3.pptx

• The UML notation for a link is a line between objects.

• If a line has a name, it is underlined.• An association connects related classes and is

also denoted by a line• When there are multiple associations, you

must use association names or association end names to resolve the ambiguity.

Page 7: class ppt_3.pptx

Multiplicity• Multiplicity specifies the number of instances

of one class that may relate to a single instance of an associated class.

• It is a subset of nonnegative integers.• UML diagrams explicitly list multiplicity at the

end of association lines.• UML specifies multiplicity with an interval,

such as “1” (exactly one), “1..*” (one or more), or “3..5” (three to five inclusive) or “*” (many/ zero or more)

Page 8: class ppt_3.pptx

Country

name

CapitalCity

name

HasCapital

1 1

India: Country

name = “India”

Delhi: CapitalCity

name = “Delhi”

HasCapital

One - to – one association

Page 9: class ppt_3.pptx

Workstation Windowconsole

1 0..1

Zero - or – one multiplicity

Page 10: class ppt_3.pptx

A BanAssociation

* *anA:A aB:B

aLink

A BanAssociation* *

anA:A aB:B

aLink

anotherAssociation* *

anotherLink

Page 11: class ppt_3.pptx

Association End Names

Person CompanyWorksFor* 0..1

employee employer

Page 12: class ppt_3.pptx

Association end names are necessary for associations between two objects of the same class. They can also distinguish multiple associations between a pair of classes

Each directory has exactly one user who is an owner and many users who are authorized to use the directory.

User Directory

*

1owner

authorizedUser *

* 0..1

*

container

contains

Page 13: class ppt_3.pptx

Use association end names to model multiple references to the same class

one person instance participates in two or more links, twice as a parent and zero or more times as a child.

Person

0..2

*

parent

child

Page 14: class ppt_3.pptx

Ordering

• Workstation screen contains a number of overlapping window

• Each window on a screen occurs at most once.• The window have an explicit order, so only the top

most window is visible at any point on the screen

Screen WindowVisibleOn1 *

{ordered}

Page 15: class ppt_3.pptx

Bags and Sequences

• A bag is a collection of elements with duplicates allowed

• A sequence ordered collection of elements with duplicates allowed

• Ordered disallows duplicates

Page 16: class ppt_3.pptx

Association Classes

• An association class is an association that is also a class

• It can have attributes and operations and participate in associations

Page 17: class ppt_3.pptx

File User

accessPermission

/etc/temp read Ram/etc/temp read-write Mohan/usr/lgn read-write Shyam

AccessibleBy

* *

Page 18: class ppt_3.pptx

Personnamedobaddress

Nameaddress

SalaryJob-title

performanceRating

boss

Manages

workerWorksFor

Company

0..1

*

* 0..1

Each person working for a company receives a salary and has a job title.The boss evaluates the performance of each worker

Page 19: class ppt_3.pptx

Qualified associations

• A qualified association is an association in which an attribute called the qualifier disambiguates the objects for a “many ” association end.

• It is possible to define qualifiers for one-to-many and many-to-many associations.

• A qualifier selects among the target objects, reducing the effective multiplicity from “many” to “one”.

Page 20: class ppt_3.pptx

BankAccount1 *

accountNumber

Not Qualified

Bank Account0..1

accountNumber

Qualified

1

Page 21: class ppt_3.pptx

StockExchange Company

tickerSymbol

* *Lists

StockExchange Company0..1

tickerSymbol *Lists

Not Qualified

Qualified