Use composition when you have a class that has a set of other objects, in any quantity. Use generalization when you have a class that shares
common properties with a set of objects, but can also have different properties or behavior. For example, a Car has components like engine,
wheels, seats, etc. This is a composition relationship. But a Vehicle is a generalization of a Car, because you can have other types of
Vehicles with different properties, like a Truck. Car and Truck are derived classes of Vehicle.
Object-oriented programming has two main objectives:
to build highly cohesive classes and
to maintain loose coupling between those classes.
High-cohesion means well-structured classes and loose coupling means more flexible, extensible software."
Cohesive means that a certain class performs a set of closely related actions. A lack of cohesion, on the other hand, means that a class is performing several unrelated tasks. Though lack of cohesion may never have an impact on the overall functionality of a particular class or of the application itself the application software will eventually become unmanageable as more and more behaviours become scattered and end up in wrong places."