QamoosTech
Architecture & DesignPatternsIntermediatePython

Cross-Cutting Concern

PronunciationKROS-KUT-ing kun-SERN

Definition

A cross-cutting concern is a need that many parts of a system share, such as logging, authentication, caching or timing. It does not belong to one feature, so it is handled in one shared place.

Where you hear it

In architecture reviews, design discussions about decorators and middleware, and code reviews that spot the same few lines everywhere.

Examples

  • Logging is a cross-cutting concern, so we add it with a decorator.
  • Authentication runs in middleware instead of inside every view.
  • Request timing is a cross-cutting concern, so one middleware records it for every route.

Common mistake

Copy-pasting the same timing or permission code into each function. One change then needs edits in dozens of places.

Don't confuse with

Separation of concerns, which is the general idea of splitting responsibilities. A cross-cutting concern is one that cuts across all the splits.

Say it at work

  • In a meeting or chatIs this a cross-cutting concern or just one feature's job?
  • In an email or ticketPull the repeated checks into one place.