Loading views...

Cross-cutting concerns

Creator
Creator
Seonglae ChoSeonglae Cho
Created
Created
2026 Feb 3 14:11
Editor
Edited
Edited
2026 Feb 3 14:15
Refs
Refs
Common functionality that appears repeatedly "across" multiple modules and layers of a program. Not directly related to business logic, but needed almost everywhere

Solutions

AOP (Aspect-Oriented Programming)

A common solution for cross-cutting concerns
Concept: Extract common functionality into "Aspects" and automatically inject them
Example:
@Before("allServices()") log(); @Around("allServices()") auth();
→ Applied automatically without writing code directly
Commonly used in Spring, AspectJ, etc.

Middleware / Interceptor

Most common in web development
Examples: Express / FastAPI / Spring
Request → Auth Middleware → Logging Middleware → Service → Response
Example (FastAPI):
@app.middleware("http") async def log_request(request, call_next): ...

Decorator / Wrapper

Commonly used in Python
@log @auth def my_func(): ...

Framework-Level Handling

Most modern frameworks provide built-in solutions:
  • Spring Security
  • Django Middleware
  • NestJS Guard
  • FastAPI Dependency
 
 
 
 
 
 

Recommendations