Performance: Why AOP matters
MEDIUM IMPACT
AOP affects runtime performance by adding method interception layers, impacting CPU usage and response time.
@Aspect @Component public class LoggingAspect { @Before("execution(* com.example.service.*.*(..))") public void logStart(JoinPoint joinPoint) { System.out.println("Start " + joinPoint.getSignature().getName()); } @After("execution(* com.example.service.*.*(..))") public void logEnd(JoinPoint joinPoint) { System.out.println("End " + joinPoint.getSignature().getName()); } }
public class UserService { public void createUser() { System.out.println("Start createUser"); // method logic System.out.println("End createUser"); } public void deleteUser() { System.out.println("Start deleteUser"); // method logic System.out.println("End deleteUser"); } }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Manual logging in each method | N/A | N/A | N/A | [X] Bad |
| Centralized logging with AOP | N/A | N/A | N/A | [OK] Good |