코드구성하기
•
육각형 아키텍쳐를 직접적으로 반영하는 패키지 구조
계층으로 구성하기
buckpal
•
domain
◦
Account
◦
Activity
◦
AccountRepository
◦
AccountService
•
persistence
◦
AccountRepositoryImpl
•
web
◦
AccountController
→ 계층으로 코드를 구성하면 기능적인 측면들이 섞이기 쉽다.
단점
애플리케이션의 기능조각이나 특성을 구분짓는 패키지 경계가 없다.
애플리케이션이 어떤 유스케이스들을 제공하는지 파악할 수 없다.
기능으로 구성하기
buckpal
•
account
◦
Account
◦
AccountController
◦
AccountRepositorty
◦
AccountRepositoryImpl
◦
SendMoneyService
→ 기능을 기준으로 코드를 구성하면 기반 아키텍쳐가 명확하게 보이지 않는다.
단점
아키텍쳐의 가시성을 떨어뜨린다.
어댑터를 나타내는 패키지명이 없고, 인커밍 포트, 아웃고잉 포트를 확인할 수 없다.
로버트마틴의 소리지르는 아키텍쳐
아키텍쳐적으로 표현력 있는 패키지 구조
•
육각형 아키텍쳐에서 구조적으로 핵심적인 요소
◦
엔티티
◦
유스케이스
◦
인커밍/아웃고잉 포트
◦
인커밍/아웃고잉 어댑터
buckpal
•
account
◦
adapter
▪
in
•
web
◦
AccountController
▪
out
•
persistence
◦
AccountPersistenceAdapter
◦
SpringDataAccountRepository
◦
domain
▪
Account
▪
Activity
◦
application
▪
SendMoneyService
•
port
◦
in
▪
SendMoneyUseCase
◦
out
▪
LoadAccountPort
▪
UpdateAccountStatePort