본문 바로가기

Design Pattern

Anti-Corruption Layer Pattern (부패 방지 계층 패턴)

# Anti-Corruption Layer Pattern 부패 방지 계층 패턴

- 패턴 이름이 ㅋㅋㅋ 부패방지... 손상방지 라고도 한다.

0. 개요, 왜 사용하는지

신규로 시스템을 개발하고, 이전하는 과정에서 일부만 일단 개발하고 나머지 시스템은 추후에 개발하는 케이스도 있을 것이다.
이렇게 되면 일부 기능만 신규로 개발이 되고 나머지는 그대로 사용해야 하는 상황이 발생한다.
그런 상황에 대비하라고 나온 게 이 부패 방지 계층 패턴이다. 아래와 같은 상황에 이 패턴을 사용하면 유용할 거 같다.
- 타 시스템 연계 (3rd party system)
- 서로 다른 통신 프로토콜을 사용할때
- 서로 다른 도메인 모델 설계
- 서로 다른 데이터 타입 사용
- 서로 다른 플랫폼 인프라 계층의 연계
서로 다른 두 시스템이 망가지는것을 방지하기 위해 중간에 도메인 모델을 변경하거나 프로토콜을 맞춰주는 부패 방지 계층을 만든다. 그러므로 서로다른 두 시스템 간의 원활한 서비스가 되도록 수행한다.

1. AWS 가이드는 아래와 같다.

https://docs.aws.amazon.com/prescriptive-guidance/latest/cloud-design-patterns/acl.html

 

Anti-corruption layer pattern - AWS Prescriptive Guidance

Anti-corruption layer pattern Intent The anti-corruption layer (ACL) pattern acts as a mediation layer that translates domain model semantics from one system to another system. It translates the model of the upstream bounded context (monolith) into a model

docs.aws.amazon.com

2. 부패 방지 계층 패턴을 아키텍처를 커스텀 해보기

- 실제로 레거시 환경과 다른 환경을 연결하는 케이스가 많을까 싶지만 그런 케이스가 있기 때문에 패턴이 나왔을 것이다.
- 일단 커스텀을 해보면 아래와 같다.

3. 부패 방지 계층 패턴을 SpringBoot로 샘플코드 만들어보기

- 샘플 코드로 구현한 로직은 아래와 같다.

- 샘플 코드는 아래에 올려 놓았다.
https://github.com/Nanninggu/Anti-Corruption-Layer-Pattern.git

 

GitHub - Nanninggu/Anti-Corruption-Layer-Pattern: About Anti-Corruption Layer-Pattern of Sample code with SpringBoot

About Anti-Corruption Layer-Pattern of Sample code with SpringBoot - Nanninggu/Anti-Corruption-Layer-Pattern

github.com

 

- 끝 -

'Design Pattern' 카테고리의 다른 글

정리해야할 디자인 패턴 목록  (0) 2024.05.15
Transactional Outbox Pattern  (0) 2024.05.14
Circuit Braker Option 테스트  (1) 2024.05.02
Event-Sourcing-Pattern  (0) 2024.05.02
Circuit breaker pattern (회로 차단기 패턴)  (0) 2024.04.26