Skip to content

Coding Convention

Sim-km edited this page Apr 5, 2024 · 6 revisions

모듈 구성

.
├── Api-Module # 스프링 실행과 presentation, application 계층을 담당하는 모듈
├── Common-Module
├── Domain-Module # 도메인들을 포함하는 모듈  
└── Infra-Module # 외부 데이터베이스 연결, API 호출을 담당하는 모듈

패키지

Api-Module(presentation,application 계층)

.
└── Api-Module/
    └── src/
        └── main/
            └── kotlin/
                └── com/
                    └── pawith/
                        ├── global
                        └── domain/
                            ├── user/
                            │   ├── presentation
                            │   └── application
                            └── todo/
                                ├── presentation
                                └── application

Domain-Module 계층

.
└── com/
    └── pawith/
        └── domain/
            ├── repository
            ├── service
            ├── exception
            ├── Util.class
            ├── Domain.class
            └── ...

Infrastructure 계층

.
└── com/
    └── pawith/
        ├── mapper
        ├── jpa/
        │   ├── entity
        │   └── repository
        ├── DomainRepositoryImpl.class
        └── ...

클래스 네이밍

Controller

  • Domain이름 + Controller

ex) UserController

Application Service

  • Domain이름 + (자원) + 행위 + Service

ex ) UserInfoGetService, UserNicknameUpdateService, UserDeleteService

  • 행위 네이밍

    • 조회 : Get
    • 수정 : Update
    • 생성 : Create
    • 삭제 : Delete

    ...

Domain Service

  • 도메인 + 행위에 대한 역할(er)

ex ) UserReader, UserModifier, UserAppender

  • 행위에 대한 역할

    • 조회 : Reader
    • 수정 : Modifier
    • 생성 : Appender
    • 삭제 : Remover

    ...

메소드 네이밍

Controller

  • http method + domain 이름 + (자원)

ex) getTodo, getTodoPregress, postTodo

Application Service

  • 조회 : get + Domain이름 + (자원)
  • 수정 : update + Domain이름 + (자원)
  • 삭제 : delete + Domain이름 + (자원)
  • 생성 : create + Domain이름 + (자원)

ex ) getUserInfo()

Domain Service

  • 조회 : read + Domain이름 + (자원)
  • 수정 : modify + Domain이름 + (자원)
  • 삭제 : remove + Domain이름 + (자원)
  • 생성 : append + Domain이름 + (자원)

ex ) readUser(), modifyUserNickname()

mapper

Application 계층 Mapper

  • 도메인 + Mapper

Infrastructure 계층 Mapper

  • 도메인 + PersistenceMapper