横切关注的例子 [英] Cross cutting concern example

查看:180
本文介绍了横切关注的例子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个交叉关注的好例子是什么?


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:

  1. 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
  2. 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.

Courtesy

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.

(Courtesy)

这篇关于横切关注的例子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆