How do you represent an attribute of a class that is a container type, such as a vector of objects of some other class?

Paul Reed

Typically this is implied when you model the classes in a class diagram. Let's say you have Customer and Order with a 1:M relationship between them (A Customer can have 0 or more orders). By defining the relationship between these two classes with a simple assocation and stating that it is navigable, then the Customer class in this case must have an attribute defined which is a Vector (or array depending on your language choice and personal considerations...although vectors allow a lot more flexibility than arrays in Java when dealing with UML associations).

The name of this attribute in Customer is really up to you. Many modeling and code generation tools, such as Rational Rose, will assign the variable name (which is of type Vector perhaps) based on the UML Role you assign at the Order-end of the association. If you don't specify a Role name, then you can choose some default naming scheme (usually something like "myOrders" or "theOrders". So, for Java, the attribute in the Customer class might look like:

Vector myOrders = New Vector();