본문 바로가기

책터디/클린 아키텍처

03. 코드 구성하기

계층으로 구성하기

soon
|-- domain
|	|-- Account
|	|-- Activity
|	|-- AccountService
|	|-- AccountRepository
|-- persistence
|	|-- AccountRepositoryImpl
|-- web
|	|-- AccountController

이 패키지 구조는 최적의 구조가 아니다.

  1. 애플리케이션의 기능 조각이나 특성을 구분 짓는 패키지 경계가 없다.
  2. 애플리케이션이 어떤 유스케이스들을 제공하는지 파악할 수 없다.
  3. 패키지 구조를 통해서는 우리가 목표로 하는 아키텍처를 파악할 수 없다.

기능으로 구성하기

soon
|-- account
|	|-- Account
|	|-- AccountController
|	|-- AccountRepository
|	|-- AccountRepositoryImpl
|	|-- SendMoneyService
  • 기능에 의한 패키징 방식은 사실 계층에 의한 패키징 방식보다 아키텍처의 가시성을 훨씬 더 떨어뜨린다.

아키텍처적으로 표현력 있는 패키지 구조

soon
|-- account
|	|-- adapter
|	|	|-- in
|	|	|	|-- web
|	|	|	|	|-- AccountController
|	|	|-- out
|	|	|	|-- persistence
|	|	|	|	|-- AccountPersistenceAdapter
|	|	|	|	|-- SpringDataAccountRepository
|	|-- domain
|	|	|-- Account
|	|	|-- Activity
|	|-- application
|	|	|-- SendMoneyService
|	|	|-- port
|	|	|	|-- in
|	|	|	|	|-- SendMoneyUseCase
|	|	|	|-- out
|	|	|	|	|-- LoadAccountPort
|	|	|	|	|-- UpdateAccountStatePort

'책터디 > 클린 아키텍처' 카테고리의 다른 글

02. 의존성 역전하기  (0) 2022.03.09