The colon and his students (serial 11)--Slice paradigm

Source: Internet
Author: User
Tags abstract aop exception handling

Slice paradigm

Transverse as the ridge side Chengfeng--"Su Shi-lin-xi wall"

The quote reopened: "OOP is in the ascendant and AOP is starting to emerge again." is AOP a branch of OOP, a complement or a transcendence? ”

Exclamation: "OOP has not fully digested, but also what AOP." ”

"Different people take different attitudes towards new things. "Colon Wang," fans tend to blindly sought after, lest outdated, they believe that the trendy popular is good; the old school tends to instinct resistance, avoid novelty, they think the classic tradition is good. ”

The quotes and the exclamation marks look at each other and reluctantly put on the old hat they were handing out.

The colon continued: "From a macroscopic point of view, there is nothing new in the sun--AOP is no more than the SOC principle and the dry principle of an application; from the microscopic point of view, the sun every day is a fresh--aop from the soil of the OOP, but from the barrier self-contained, and grafted to the non-OOP Not only in the pure process language, functional language, and even logical language development, but also has a certain declarative language features, as a new way of software modularization. ”

Question mark Raise your hand: "What is SOC and dry?" ”

Quotation mark: "Soc is separation of concerns, which is separation of concerns; dry is don ' t Repeat yourself, that is, to minimize duplication of code. ”

"The answer is right, add very!" "Colon play praise Way," bad code usually has two kinds of symptoms: one is chaotic including, entanglement knot, can be said to cut the reason still disorderly, two is duplication, bloated unbearable. An effective way to treat this type of illness is to abstract and decompose: abstract some concerns from the problem and then decompose it on this basis. The sub problem after decomposition is distinct and independent and does not far-reaching. Part of the same feature can be extracted as the common factor in algebra, reducing code duplication. ”

"This is not a modular?" he said. ”

"To be exact, abstraction is a prerequisite, decomposition is a way, and modularity is the result." "The colon is very precise," you remember Sunding's story? In the ordinary eyes of the complex cattle, paoding through abstraction, has been Parvoy, until the knife decomposition, naturally with ease. When the cattle, such as the Land Committee, Modular. ”

Period Extrapolate: "Most of the basic ideas of the programming paradigm mentioned above are not the same?" The process, function, assertion, object, and process are decomposed into processes, functions, assertions, objects and processes, which in turn become procedural, functional, logical, object and concurrent. As for the generic type--"

The end of the period cannot be said anymore.

"Generics do not introduce new types of modules, the core of which is the abstraction of the algorithm and data decomposition." "Colon clears it," and so on, cut-style AOP decomposes the abstraction of the program into slices. ”

Question mark question: "What is the principle of abstraction and decomposition?" ”

The colon is a V: "Two: Single, orthogonal." Each module has a well-defined responsibility, and the modules are independent of each other, i.e. high aggregation and low coupling (cohesion & coupling). This principle is quite universal, is a basic method of analyzing complex things, especially in mathematics and physics, such as qualitative factorization, orthogonal decomposition, spectral decomposition and so on. ”

The comma playfully: "Why is it called orthogonality?" Is it not possible to skew the intersection? ”

The colon chuckled: "The two orthogonal vectors are projected to zero in each other's direction, which means they are independent and have no influence on each other. ”

The comma vomited and spit out his tongue.

"As mentioned earlier, AOP takes slices as a module." "The colon Returns the theme," aspect is often interpreted as ' aspect ', but it describes crosscutting concerns (cross-cutting concerns), so ' cut ' is more accurate and vivid, and ' aspect ' is empty and dull. What is crosscutting concern? As the name suggests, it is the vertical mainstream of the program with the direction of horizontal orthogonal focus. It is worth recalling that both procedural and object-style methods contain complete code execution. But some of the code across multiple modules, in the form of fragments scattered everywhere, although with similar logic, but can not be refined into a traditional way module, it is difficult to achieve SOC and dry. Typical examples are the use of unified business logic, such as log output, code tracking, performance monitoring, exception handling, security checks, transaction management, and so forth, before and after invoking the methods of certain objects, reading and writing fields of certain objects, throwing certain exceptions, and so on. To solve such problems, AOP emerged. It encapsulates each type of crosscutting concern in a separate aspect module, binding some execution points in the program to the appropriate code. A single point of execution is called an access point (join points), such as before and after a method that invokes an object, and an access point set that conforms to a predetermined condition is called a pointcut (pointcut), for example: all methods that start with set, and each bound code is called a recommendation (advice). ”

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.