Aop__java of--spring Framework decrypted by Java architecture

Source: Internet
Author: User

Has always been, we have applied a lot of AOP framework, but for the low-level implementation of AOP is not too much depth, the saying is "know it, do not know why", with the sudden rise of AOP academic discussion, I also opened up their horizons, in-depth understanding of the colorful AOP of the world.


Let's take a look at the public definition:

Baidu Encyclopedia:

In the software industry, AOP is the abbreviation of Aspect oriented programming, which means that it is a kind of technology for cutting plane programming and realizing the unified maintenance of program function through the way of precompilation and dynamic agent. AOP is a continuation of OOP, a hotspot in software development, an important content in spring framework, and a derivative paradigm of functional programming. The use of AOP can isolate the parts of the business logic, so that the coupling between the parts of the business logic is reduced, the reusability of the program is improved, and the efficiency of the development is improved.


Wikipedia:

Side-oriented programming (Aspect-oriented PROGRAMMING,AOP, also translated aspect-oriented programming, view-oriented program, profile-oriented program design) is a term in computer science that refers to a programming paradigm. The paradigm is based on a language construct called the side (aspect, and translation aspect), and the side is a new modular mechanism for describing crosscutting concerns (crosscutting concern) that are dispersed across objects, classes, or functions.

The concept of the side is derived from the improvement of object-oriented programming, but not limited to this, it can also be used to improve traditional functions. Side-related programming concepts also include meta object Protocols, topics (subject), mixing (mixin), and delegates.


Looking at the definitions of these fanfan, I'm dizzy too, but we can go deep into the simplest questions, and the simple question is "Why are we programming?" ”

My answer to this question is, in order not to program. We create functions, create classes, create frameworks, create software, and create Ides for what. is to step by step to eliminate the duplication of human work. is to liberate people, let people play the greatest characteristics of people, is to think and summarize.

Along this line of thought, we'll restore the initial appearance of AOP: 1, discard replication.

In the original program design, we need to write a log for each of our classes, transaction control. Our program Ape honestly wrote n much log processing and transaction processing. When one day, there is a program ape suddenly said, I am tired of such a heavy work, I must take the repeated parts of the code into the public class to deal with.

Diagram:



2, dependency inversion

After a period of time, an ape is not satisfied, because I still want to call the public class for each class, he looked at the design pattern, found that the agent is a good solution, if the use of dynamic agents, it is more interesting

Diagram:



Two kinds of dynamic proxy diagram



3,AOP

After a while, programmers combine dynamic proxies with the IOC, writing a framework called the AOP Framework, free of charge to all who need this business, and Java has one more concept, that is, AOP


Conceptual schematic:



Summary:

At the beginning of the computer's birth, is in order to do some repetitive simple work, with the depth of computer technology, our original intention, has not changed, the computer's greatest advantage is to repeat, as a program designer, in all the work of employees, we should consider whether this work is necessary. Is this job a pure copy? Can you give this job to the computer? This job is not a person to do, we can use it. These tasks not only require the experience of the designer, but also the abstraction of the business and the ability to control the overall architecture.

As a 21st Century program designer, are you still letting employees do unnecessary copy?


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.