Composition
The next basic concept of object-oriented programming to introduce is that of composition.
Composition is the concept that an object cannot exist without its composite parts. In essence, it is the process of creating an object from a combination of other objects.
A common way to show this example is in the form of a car. Many objects go into making a car. Some of them are 'optional extras' and trimmings from the dealership such as a cup holder or satellite navigation system, whereas others are crucial for the existence of the car, such as an engine or wheels.
The following UML diagram provides another helpful visualization of composition:
Composition is represented in UML as a filled diamond shape and a solid black line.
An engine on its own is just an engine. In true object-oriented practices, as an object it cannot exist without the car such as its parent object. Similarly, a car is an object, but is nothing without an engine.
On their own, these objects are not of much use...