Improve code encapsulation and reusability through AOP

Source: Internet
Author: User
Tags aop exception handling
[Introduction]
Aspect-oriented programming (AOP) is a programming paradigm invented by Xerox PARC in the 1990s s of the Xerox Corporation, it allows developers to better separate tasks that shouldn't be entangled with each other (such as mathematical operations and exception handling. The AOP method has many advantages. First, because the operation is more concise, the performance is improved. Second, it allows programmers to spend less time rewriting the same code. In short, AOP can provide better encapsulation for different processes and improve future interoperability.
What makes software engineers want to become hardware engineers? Since the invention of the function, programmers have spent a lot of time (and most of their boss's money) trying to design such a system: they are just a combination of models, made up of parts created by others, it is arranged in a unique shape and then covered with some pleasing colors. Functions, templates, classes, components, and so on are all attempts by software engineers to create "software integrated circuits" (simulating the electronic devices of hardware designers.
All of these are attributed to Lego ). The cool Click made when two pieces of toys (that is, components) are combined is addictive, which will prompt many programmers to invent a new encapsulation and reuse mechanism. The latest developments in this area are called Aspect-Oriented Programming (AOP: Aspect-Oriented Programming ). The core of AOP is to arrange components (one stacked on the other), so that you can obtain the level of reuse that cannot be obtained by other component-based development methods. This arrangement is performed in the call stack between the client and the object. The result is that a specific environment is created for the object. This environment is exactly what AOP programmers are pursuing. Continue to read this article and you will understand this.
The sample code provided in this article is divided into two parts: COM and Microsoft. NET. A basic structure is created for the COM part. You can add an Aspect to the COM object (Editor's note: The original English text is Aspect, and the word is translated as "Aspect" after this article "), the user interface is provided to configure the class, and an example is provided for implementation in the basic structure we provide.
The. NET section describes how to use the built-in. NET infrastructure to complete the same job for the COM version, but the code is less and more options are used. It also provides examples that suit this infrastructure. This article will describe all these codes later.
What is AOP?

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.