Skip to content

BE Code Conventions

niireymik edited this page Apr 17, 2025 · 1 revision

Conventions

Motivation

  • As code get complicated, documentation is need for the better development environment

    • To understand a function, a developer needs to read the every lines of function to guess what it does.

      "Code is more often read than written"

      - Guido van Rossum

Naming Convnetion

Java

  1. Variable, Function - camelCase: starts with a lowercase letter, words separated by uppercase first letter of the next word

    • e.g. userName, createAt
    • e.g. getUser(), saveUser()
  2. Class - PascalCase: starts with an uppercase letter, words separated by uppercase first letter of the next word

    • e.g. UserController, GetUserBean
  3. url - kebab-case : words separated by hyphen(-) with all letters lowercase

    • e.g. post-heart, create-at

Git commit Convention

Commit Type

  • feat: 새로운 기능 추가
    • ex) feat: 공지 조회 api 추가
  • fix: 버그 수정
    • ex) fix: 공지 조회 api 정렬 버그 수정
  • docs: 문서 수정
    • ex) docs: readme 문서 작성
  • style: 코드의 수정은 없지만 문법 및 변경사항 수정
    • ex) style: for each 문 stream()으로 변경
  • refactor: 코드 리펙토링
    • ex) refactor: 공지 조회 공통 기능 small Bean으로 모듈화
  • 'rename`: 파일명 폴더명 수정
    • ex) rename: GetNotificationDAOsBean -> GetNotificationDAOBean
  • remove: 파일 삭제
    • ex) remove: GetNotificationDAOsBean 삭제
  • comment: 주석 추가 및 변경
    • ex) comment: 공지 조회 기능 관련 주석 추가
  • test: 테스트코드 추가 및 변경
    • ex) test: GetNotificationDAOBean 테스트 코드 작성

Github Pull Reqeust Convention

  • If you need to add or modify a new code such as modification or function addition, create a branch and make a pull request. In the pull request, the reviewer is always @seeungmin

  • When requesting Pull reqeust, write markdown according to the template form.

## Docs

- [Issue Link]()

## Changes

- before :
- after :
- images

## Review Points

#### Problem

#### Solution

## Test Checklist

- [ ] check 1
- [ ] check 2
  • If there are issues, manage comments through numbering.

  • Manage other issues by writing additional comments.

  1. Commit Convention Issue

  2. Indentation Issue

  3. Comment Issue

  4. Class Naming Issue

  5. Variable Naming Issue

  6. Code Separation Issue

Method Naming Conventions for Controller and Service

Method names in Controllers and Services should start with CRUD-based verbs:

  • check
  • get
  • save
  • update
  • delete

DAO and DTO Naming Conventions

Append DAO to the end of every entity name:

  • NotificationDAO

DTOs are divided into two categories:

  • ResponseDTO
    • Used for GET requests
    • Format: Response(DAOName)GetDTO
  • RequestDTO
    • Used for other requests
    • Format: Request(DAOName)(MethodName)DTO
  • For additional cases, provide feedback as they arise.

Bean Method Naming Conventions

Method names for Bean and small Bean classes should be unified as exec.

  • Use overloading to differentiate methods.
  • Bean Naming Conventions:
    • GetNotificationBean
    • GetNotificationsBean
  • Small Bean Naming Conventions:
    • GetNotificationDAOBean
    • CreateNotificationDTOBean
    • CreateNotificationDAOBean

Repository Naming Conventions

Append RepositoryJPA to the entity name:

  • NotificationRepositoryJPA

Clone this wiki locally