Easy-to-go AOP and IOC

Source: Internet
Author: User
I. AOP example 1, Google Toolbar: Block pop-up windows, add links to Amazon for ISBN

The original HTML document knows nothing about Google Toolbar's hands and feet, and toolbar gets the original document and begins to weave the code into it based on a specific matching condition:

If you have code that calls a pop-up window, insert a comment around the code

If there is an ISBN number, insert a link for this text <a href= "Http://www.amazon.com/isbn=xxxx" >

The final display in the browser, will be less pop-up window code, more than the ISBN link 2, ctor/dtor

In fact, the traditional support object-oriented language has unconsciously included the idea of what is now called AOP, which is the constructor and destructor: The compiler automatically inserts code when object creation and object destruction, where aspect is "the time to automatically manage resource acquisition and release for objects"; This idea expands, For example, if you insert code when entering or exiting a particular function, it is AOP II. Example of the IOC elevator

Even though I had already started to get higher education, I still made mistakes when I used the elevators a couple of times: when I wanted to go down to the first floor on the upper floor and when the elevator was on the lower floor, my first reflection was to let the elevator come up to me, so I pressed the "up" button and the elevator didn't start down as I hoped But to continue upward; and then I was in the hospital, and I observed a lot of the families of the patients who came from the countryside without contacting the elevators, and constantly making the same mistakes.

In fact, the use of elevators is simple: when you want to press the "next", when you want to press "up", you can, when you want to "control" the elevator, things become troublesome

So the idea of the elevator and the IOC is the same: Speak your needs, the control behind the system.

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.