AOP C # in action

Source: Internet
Author: User
Tags aop
Read a book, the title is "Ascpectj in action", just this section of the project to engage in a paragraph, so there is a little leisure, decided to write something.

AOP is a shorthand for aspect-oriented programming. The Chinese translation of this aspect has been a no-brainer, and there is a similar AOP, that is attribute-oriented programming, so someone is translating aspect-oriented programming, and the latter is feature-oriented programming. Feature-oriented programming can be justified, always feel that aspect-oriented programming translation of some strange, a Chinese understanding does not understand: what is aspect-oriented? Or by the Taiwanese habit of "aspect oriented"? Ah, unintelligible. An accidental idea, aspect and the form of the solution, this form is not what we usually call the form of ideology, that is the form of thought, is invisible, this form refers to the object expressed in some form (its behavior, characteristics, etc.). So, I personally think AOP translation seems to be more appropriate for shape-oriented programming.

AOP research has become a hot topic, and the description of AOP has been described in more detail in the CSDN article, as well as some controversy over the description. The AspectJ in action description I think is the most classic, on the grounds that the book is written by AspectJ developers, and AspectJ is currently one of the most sophisticated AOP tools.

Interception of method calls has been interpreted as an interpretation of AOP, as most people do, I don't think so. The main role of AOP is to solve the horizontal relationship between objects, an orthogonal and intricate relationship. Traditional OOP is not very good or easy to solve this problem. This is one of the reasons AOP has the opportunity to flourish. So how does AOP solve this problem? Weaving (Weave), which weaves together the related behaviors of objects according to specific rules. The interception mentioned above is just a means to complete weaving. Interception is not an end, weaving is. In turn, weaving is not just interception, it includes a variety of knowledge and technology. This weaving process can be either static or dynamic, like early binding and late binding in OOP.

The title of this article mentions C # (sorry, C # is one of my favorite languages), because AOP research in C # is a few years behind the research in Java. There is almost no application-level (at least Java also has a ASPECTJ, the current version is 1.2). Perhaps I am ignorant, the network can find the more well-known I am afraid only loom and aspect#, said they still belong to the laboratory results not too much. Does that mean that AOP is difficult to implement in C #? Answer: Yes, neither. The language features of Java and C # are so much alike (they have common ancestor C + +). There is no reason to say that Java can be implemented, and C # is not. So where's the problem? This is the study of C # 's AOP, and most people insist that the existing C # language specification cannot be modified and can only be extended to the C # language. The resulting assembly (Assembly) must be able to be invoked and executed by the CLR. Also consider the performance of the program. If MS is not in C # or even. NET of AOP built-in support (such as the current extension of generics), then the difficulty must be there.

Fortunately, MS does not completely ignore AOP, and in the design of the. NET Framework class library, we can vaguely find AOP design ideas (although this is the approach that Ms Class library implementations use to solve specific problems). This also provides a design idea for us to implement AOP in C #. Nevertheless, there are still many problems to be solved.


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.