Certification/Spring(2V0-72.22, SCP)

What is the concept of AOP? Which problem does it solve? What is a cross cutting concern?

엘호리스 2021. 11. 6. 12:33

What is the concept of AOP? Which problem does it solve? What is a cross cutting concern?

  • Name three typical cross cutting concerns.
  • What two problems arise if you don’t solve a cross cutting concern via AOP?

What is the concept of AOP?

  • Introduction
    • Aspect-oriented programming (AOP) is an approach to programming that allows global properties of a program to determine how it is compiled into an executable program.
    • declaring additional methods or fields on behalf of a type
    • additional data or method to existing types, implementing new interfaces
  • Join point
    • A point during the execution of a program,
  • Pointcut
    • A predicate that matches join points.
  • Advice
    • Advice is an action taken by an aspect at a particular join point.
  • Weaving
    • linking aspects with other application types or objects to create an advised object.
  • Aspect
    • An aspect is a class that implements enterprise application concerns that cut across multiple classes, such as transaction management.
유형 설명
Joinpoint 지점 및 위치 Advice가 수행될 위치. 메소드 실행 시점이 기준.
Pointcut 지점을 가르키는 표현식 특정 메소드(지점)를 지정하는 표현식으로 @Pointcut 어노테이션을 사용하여 지정.
Advice 해당 지점에서 수행할 동작 수행 로직이라고 봐도 무방
Weaving 해당 지점에 수행 동작을 삽입하는 행위 실을 교차하여 직물을 짜는것을 연상하면 이해가 쉬움. 기존 수직적으로 수행중인 로직에 특정 시점에 수행할 로직을 가로측으로 엮는듯한 행위.
Aspect Spring에서 제공하는 AOP 구현 클래스 Spring에서 제공하는 AOP 구현을 모듈화 하기 위한 클래스. @Aspect 어노테이션을 통해 컴포넌트 구현.

Which problem does it solve?

  • Aspect-Oriented Programming makes it possible to do certain types of programming that are difficult to do without unnecessarily scattering code throughout your application or library that is unrelated to the primary functions of your software (i.e. cross-cutting concerns). Examples include:
    • Logging and Monitoring
    • Performance analysis
    • Debugging and Tracing
    • Undo Functionality
    • Validation of inputs and outputs
    • Morphing the behavior of existing objects
    • Object Filters
    • Security Implementation
    • Managing transactions

What is a cross cutting concern?

  • In aspect-oriented software development, cross-cutting concerns are aspects of a program that affect other concerns. These concerns often cannot be cleanly decomposed from the rest of the system in both the design and implementation, and can result in either scattering (code duplication), tangling (significant dependencies between systems), or both.

  • For instance, if writing an application for handling medical records, the indexing of such records is a core concern, while logging a history of changes to the record database or user database, or an authentication system, would be cross-cutting concerns since they interact with more parts of the program.