All people with philosophical foundations know that motion is absolute and static is relative.
Since the static language exists objectively, he must follow this path.
But how can we change static to dynamic?
Fortunately, we have two magic weapons: Polymorphism and reflection. Using these two magic weapons, we can achieve the object's runtime state.
How to Use reflection to dynamically load beansArticle,CodeThere are quite a few examples.
For more information, see spring practices.
Articles about how to bind a runtime using polymorphism and interfaces are also available on the Internet.
Static as dynamic. Currently, we know that only delayed binding and dynamic loading can be used to implement weak coupling between objects.
In fact, the use of reflection is open to question.
The most frequently used method of reflection is to set bean attribute relationships to XML files.
ProgramThe employee's work is displayed in XML format in front of the end user. What are the consequences?
This may make the programmer's design outstanding,
However, this increases the coupling between code and XML files.
The Coupling Degree of a system is fixed, and the coupling degree between codes is reduced,
The coupling between files and files is inevitable.
All programmers have to do is to balance these options, not be too flexible, all in the form of configuration files,
And cannot all be coupled in the code.
Turn static to dynamic.