横切关注的例子 [英] Cross cutting concern example
问题描述
一个交叉关注
的好例子是什么?
What is a good example of a cross-cutting concern
? The medical record example on the wikipedia page seems incomplete to me.
Specifically from this example, why would logging lead to code duplication (scattering)? (Besides simple calls such as log("....")
everywhere, which doesn't seem like a big deal).
What is the difference between a core concern
and a cross-cutting concern
?
My end goal is to get a better understanding of AOP.
Before understanding the Crosscutting Concern, we have to understand the Concern.
A Concern is a term that refers to a part of the system divided on the basis of the functionality.
Concerns are two types:
- The concerns representing single and specific functionality for primary requirements are known as core concerns.
OR
Primary functionlity of the system is knows as core concerns.
For example: Business logic - The concerns representing functionalities for secondary requirements are referred to as crosscutting concerns or system-wide concerns.
OR
The crosscutting concern is a concern which is applicable throughout the application and it affects the entire application.
For example: logging, security and data transfer are the concerns which are needed in almost every module of an application, hence they are cross-cutting concerns.
This figure represents a typical application that is broken down into modules. Each module’s main concern is to provide services for its particular domain. However, each of these modules also requires similar ancillary functionalities, such as security logging and transaction management. An example of crosscutting concerns is "logging," which is frequently used in distributed applications to aid debugging by tracing method calls. Suppose we do logging at both the beginning and the end of each function body. This will result in crosscutting all classes that have at least one function.
这篇关于横切关注的例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!