Java architecture decryption-AOP of Spring framework

Source: Internet
Author: User

Java architecture decryption-AOP of Spring framework

We have been using a lot of AOP frameworks for a long time, but we haven't gotten too deep into the underlying implementation of AOP. In the old saying, "I know it, I don't know why ", with the rise of the academic discussion on AOP, I have also opened up my own horizons and learned more about the colorful world of AOP!

 

Let's take a look at the definition of the public:

Baidu Encyclopedia:

In the software industry, AOP is short for Aspect Oriented Programming. It is a technology that implements unified maintenance of program functions through pre-compilation and dynamic proxies during runtime. AOP is a continuation of OOP and a hot spot in software development. It is also an important part of Spring framework and a derivative model of functional programming. AOP can be used to isolate all parts of the business logic, thus reducing the Coupling Degree between each part of the business logic, improving the reusability of the program, and improving the development efficiency.

 

Wikipedia:

Aspect-oriented programming (aspect-oriented programming and AOP) is a term in computer science, A programming paradigm. This model is based on a language structure called the side (aspect), and the side is a new modular mechanism, used to describe the cross-concern (crosscutting concern) distributed in objects, classes, or functions ).

The concept on the side is derived from the improvement of object-oriented programming, but it is not limited to this. It can also be used to improve traditional functions. The aspect-related programming concepts also include meta-Object Protocol, subject, mixin, and delegate.

 

After reading the definitions of these models, I am also dizzy. However, we can go deeper from the simplest question. This simple question is "Why do we program ?"

My answer to this question is to avoid programming! What are the purposes of creating functions, classes, frameworks, software, and IDE? It is to eliminate human repetitive work step by step! It is to liberate people and let people exert their biggest characteristics, that is, to think and to sum up!

Following this idea, we will restore the original appearance of AOP:

1. Discard replication!

In the initial program design, we needed to add logs and transaction control for each class we wrote! Our program has honestly written more than N log processing and transaction processing! One day, a programmer suddenly said that I was so tired of such a heavy job that I must take the repeated parts of the Code to the public class for processing!

:

 

2. Dependency inversion

After a period of time, some ape was not satisfied, because I still had to call the public class for each class, and he looked at the design mode and found that proxy is a good solution, it is even more interesting to use dynamic proxy.

:

 

Two Dynamic proxies

 

3. AOP

After a while, the programmer combined dynamic proxy with IOC and wrote a framework called the AOP framework, which was provided free of charge to anyone who needed the service, java has another concept, that is, AOP.

 

Concept:

 

Summary:

At the beginning of computer science, we started to do some repetitive and simple work for people. With the development of computer technology, our original intention has never changed. The biggest advantage of computer science is repetition, as a programmer, should we all consider the work of all employees? Is this necessary? Is this work pure copy? Can I submit this job to a computer? Is this work done by one person, and everyone can use it? These jobs require not only the experience from the designer's mind, but also the ability to abstract the business and control the overall architecture!

As a programmer in the 21st century, are you still letting employees do unnecessary copies?

 

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.