Turn static into dynamic

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.