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 to have a collection class as a return type?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You may consider to use an “association”. There are three basic types of association: composition, aggregation and “normal” association. Each of them expresses a different existential dependency of the whole to the part and vice versa.
Usually associations are expressed by connecting two classes by a line. Composition and aggregation have a diamond symbol at the composite’s/aggregate’s side. The composite/aggregate consists of one or more parts. (See the wiki-article)
Example:
Immagine you have two classes: Library, Book. We can say the Library is the whole and Book the part. We could notate it like this (in ASCII, please google for real diagrams).
Library (Aggregate) <>— Book (Part)
If you want to express these relationships association will be your friend.
EDIT:
As I said in the comment, I don’t think there is a special notation for returned collections. However, you’re right, returning a Collection is kinda language specific. But you may consider to return an array (
String[]), which is a more general way to represent a set of values and should be more language independent than a Collection. It’s then up to the programmer how he implements it. He may use aCollection, a C++ STL vector … the point is: return a set of values.