TIL

03. 코드 구성하기

계좌에서 다른 계좌로 돈을 송금하는 유스케이스를 예제로 육각형 아키텍처를 직접적으로 반영하는 표현력 있는 패키지를 소개하겠다.

계층으로 구성하기

buckpal
|---- domain
     |---- Acount
     |---- Activity
     |---- AccountRepository
     |---- AccountService
|---- persistence
     |---- AccountRepositoryImpl
|---- web
     |---- AccountController

기능으로 구성하기

buckpal
|---- account
     |---- Acount
     |---- AcountController
     |---- AccountRepository
     |---- AccountRepositoryImpl
     |---- SendMoneyService

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

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

의존성 주입의 역할