Differences between intrusive and non-intrusive

Source: Internet
Author: User
From Spring framework technology, Spring framework is a lightweight non-intrusive framework. non-Intrusive technology allows you to freely select and assemble various functional modules of the Spring framework in the application system, in addition, the class of the application system is not required to inherit or implement an interface from a class of the system API of the Spring framework. 2. how to achieve non-intrusive design goals 1) Application reflection mechanism, provide various functions through dynamic calling, and establish beanfactory between core groups 2) use the beanwrapper and beanfactory component classes in the Spring framework to create an object instance and inject attributes. 3) Advantages: allow the developed application system to be freely transplanted in an unused environment, the code that does not need to modify the core function implementation in the application system is reprinted: Let me briefly explain my understanding. Let's assume that everyone wants to plug user code into a framework. The intrusive approach is to require the user code to "know" the code of the framework, as the user code needs to inherit the class provided by the framework. Non-intrusive, you do not need to introduce the Framework Code into your code. From the perspective of the class writers, you cannot notice the existence of the framework.
For example:
When using struts, I need to inherit some struts classes, and Struts intrude into my code.
When using spring, you do not need to inherit spring-specific classes when writing some business classes. You can use it after configuring dependency injection. At this time, spring does not intrude into the code of my business classes.

Intrusive allows user code to generate dependencies on the framework. These codes cannot be used outside the framework, which is not conducive to code reuse. However, intrusive methods allow users to better integrate with the framework and make full use of the functions provided by the framework.
Non-Intrusive Code does not have too many dependencies and can be easily migrated to other places. However, the interaction with user code may be complicated.

Both of these methods have their own advantages and disadvantages. They mainly depend on how they are weighed during actual development.

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.