Let's first create a question to write the running results of the following programs:
Public class test {<br/> Public static void main (sting ARGs []) {<br/> child = new child (); <br/>}</P> <p> Class Parent {<br/> parent () {<br/> system. out. println ("parent. "); <br/>}</P> <p> class delegate {<br/> delegate () {<br/> system. out. println ("delegate. "); <br/>}</P> <p> class Child extends parent {<br/> child () {<br/> system. out. println ("child. "); <br/>}</P> <p> delegate = new delegate (); <br/>}
Class diagram of the previous program:
The output result is as follows:
Parent.
Delegate.
Child.
We can see that the direction of the inherited arrow is set to the direction that the parent class represents the dependency. Dependency refers to a relationship between two elements. One element changes and another element changes. In UML, a hollow arrow pointing from the subclass to the parent class is used to represent inheritance, which implies that changes in the parent class may lead to changes in the subclass.
Back to the question, according to the original "dependent first constructor, dependent on the human latter constructor", class child inherits from Class Parent, meaning that the former depends on the latter, the child's clustering relationship for delegate also means similar dependencies.
This article draws from Chapter 24th of "Software Architecture Design" by using Graph Theory to learn UML.