UML (Unified Modeling Language) diagrams to visualize relationships among classes and objects.
A UML class diagram consists of one or more classes, each with sections for the class name, attributes, and methods. Depending on the goal of the diagram, the attribute and/or method sections can be left out of any class. In a UML diagram, each class is represented as a rectangle, possibly containing three sections to show the class name, its attributes (data), and its operations (methods).
Keep in mind that UML notation is not intended to describe a program after it is written.
It’s primarily a language-independent mechanism for visualizing and capturing the design of a program before it is written.
Take a look at these 3 scenarios:
association
When classes are “aware” of each other, objects of those classes may use each other this often is referred to as a “use relationship”.
In the next example, the line connecting FlipRace and Coin indicates a basic association. The number 2 represents the association between FlipRace and 2 Coin objects.
aggregation
Some objects are made up of other objects. A car, for instance, is made up of its engine, its chassis, its wheels, and several other parts. Each of these other parts could be considered separate objects. Therefore we can say that a car is an aggregation—it is composed, at least in part, of other objects. Aggregation is sometimes described as a “has-a relationship”. For instance, a car has a chassis.
In UML, aggregation is represented by a connection between two classes, with an open diamond at the end near the class that is the aggregate. Strings are so fundamental to programming that they are usually represented the same way a primitive attribute is represented.