UML - object method Returns a collection

How can I indicate that a method will return a collection of objects in UML? Is there a better way to explain the relationship than having a collection class as a return type?

+5
source share
4 answers

You can use the "association". There are three main types of associations: composition, aggregation, and “normal” association. Each of them expresses a different existential dependence of the whole with the part and vice versa.

Associations are usually expressed by joining two classes in a row. Composition and aggregation have a diamond symbol on the side of the composite / aggregate. The composition / assembly consists of one or more parts. (See wiki-article )

Example:

You have two classes: library, book. We can say that the library is a whole and remembered this part. We could put it this way (in ASCII, please google for real diagrams).

Library (Unit) <> --- Book (part)

If you want to express this relationship, the association will be your friend.

EDIT:

, , . , , , . (String[]), , Collection. , . Collection, ++ STL... : .

+4

, . , - .

, ? , 0.. * 1.. *. , , .

. Library < > --- Book, , GetBooks, , . UML :

+ GetBooks (authorName: string): [0.. *]

UML ; Magic Draw. UML , GetBooks 0 . , ( ).

+7

, , UML . , UML , , UML UML . - (OCL), UML ( OMG) .

0

.

, 1.. * .

For example, if you want to return a collection of the Book class, create a new Books class with the association 1 .. * with Book and use the Books class as the return type.

0
source

All Articles