Dependency is a good distinction, it is the weakest coupling, in Java as local variables, method parameters, or calls to static methods, such as the following example: Driver class depends on the car class, driver three methods to demonstrate the dependency of the three different forms.
Association relationships are typically implemented in Java using member variables, sometimes in the form of method parameters. Still using driver and car examples, using the method parameter form can represent a dependency or an association relationship, after all, we cannot express semantics too accurately in the program. In this example, the member variable is used to express the meaning: The car is my own car, I "own" the car. Using the method parameter expression: The car is not mine, I am just a driver, others give me what car I will drive what car, I use this car.
The aggregation relationship is a relatively strong association, which is generally implemented in Java using the member variable form. There is a whole and a part relationship between objects. For example, in the previous example
To represent a combined relationship, the constructor is often used to achieve the purpose of initialization, such as in the example above, plus a construction method with the car parameter
public
Driver(Car car){
mycar = car;
}
Basic concept of design pattern