Performance: Cross-cutting concerns concept
This concept affects application startup time and runtime performance by adding layers that intercept core logic.
@Aspect @Component public class LoggingAspect { @Before("execution(* com.example..*(..))") public void logStart() { /* logging logic */ } }
public void process() { logStart(); checkSecurity(); // core logic logEnd(); } // repeated in every method| Pattern | Code Duplication | Runtime Overhead | Maintainability | Verdict |
|---|---|---|---|---|
| Manual code duplication | High | High | Low | [X] Bad |
| Aspect-Oriented Programming (AOP) | Low | Medium | High | [OK] Good |
@Aspect.@Aspect
public class LoggingAspect {
@Before("execution(* com.example.service.*.*(..))")
public void logBefore() {
System.out.println("Method called");
}
}com.example.service package is called?@Before annotation means the method logBefore() runs before the matched method executes.execution(* com.example.service.*.*(..)) matches any method in any class inside com.example.service package.@Aspect
public class SecurityAspect {
@Before("execution(* com.example..*(..))")
public void checkSecurity() {
// security check code
}
}execution(* com.example..*(..)) has invalid syntax because it is missing the method name pattern .*. Correct syntax is execution(* com.example..*.*(..)) to match any method in com.example package and subpackages.@Transactional in your Spring Boot app. Which pointcut expression correctly targets these methods?@annotation pointcut designator with the full annotation class name.@annotation(org.springframework.transaction.annotation.Transactional), which correctly matches methods annotated with @Transactional. Other options are invalid or incorrect syntax.Pass the test and this pattern moves unknown