Relationship between "Java and Mode" learning notes
Between the class and classes, there will be a connection to indicate the relationship between them. Relationships include the following:
General relationship:
The general relationship represents the inheritance relationship between classes and classes, inheritance relationship between interfaces and interfaces, or realization of classes to interfaces. The generalization relationship is the interface that points from the subclass to the parent class, or from the class that implements the interface. Such as:
connection relation:
The association relationship is a connection between classes and classes that makes a class to another class of properties and methods. Association relationship is generally implemented using instance variables. Such as:
At each associated endpoint, there can be a base, indicating that the class of this end can have several instances. Common bases are as follows:
Base Meaning 0 ... .1 Zero or An Example 0 ... * or * The number of examples is not limited to 1 only one instance 1 .... * At least one instance
Polymerization:
A polymerization relationship is a kind of association relationship is a strong relationship. The polymerization is the relationship between the overall and individuals. For example: the relationship between automotive and engine, tire class.
Like the relationship, the polymerization relationship is also achieved by instance variables. However, the two classes involved in the association relationship are at the same level, and in the polymerization relationship, one representative of two classes is a representative part.
Synthetic relationship:
Synthetic relationships are one of the relationships of the relationship and is a strong relationship with a polymerization. It requires a general aggregation relationship to represent the overall object to be responsible for the life cycle of the object representing the object, and the synthetic relationship cannot be shared. That is to say, the object representing the object can only be synthesized with an object at a certain moment, and the latter is responsible for its lifecycle.
Dependency:
Dependencies are also connected between classes and classes, depending on always one-way. Dependencies represent a definition of another class. A person can buy a car and a house, depending on the car and a house. Different from the association relationship, the properties of the CAR and HOUSE types in the Person class are incoming to the Buy () method in the form of parameters. Such as:
Class Person
{
Public void Buy (Car Car)
{
}
Public void Buy (House House)
{
}
}
In general, dependence is reflected in Java as a local variable, method of the method, and the call to static methods.