Skip to content

refactor(clean-code): goodcode 학습 테스트에 @Nested 카테고리 그룹화 적용#13

Merged
jaeyeonling merged 4 commits intocho-log:mainfrom
yesjuhee:refactor/nested-grouping-clean-code
Apr 6, 2026
Merged

refactor(clean-code): goodcode 학습 테스트에 @Nested 카테고리 그룹화 적용#13
jaeyeonling merged 4 commits intocho-log:mainfrom
yesjuhee:refactor/nested-grouping-clean-code

Conversation

@yesjuhee
Copy link
Copy Markdown
Contributor

@yesjuhee yesjuhee commented Apr 4, 2026

Summary

clean-code 모듈의 goodcode 패키지 테스트 3개(ReadableCodeTest, PredictableCodeTest, AvoidMistakeCodeTest)에 @Nested를 적용하여 학습 카테고리별로 그룹화합니다.

배경

다른 학습 테스트들은 모두 @Nested로 그룹화되어 있으나, goodcode 테스트들은 @Nested 없이 테스트가 순차적으로 나열되어 있어 처음 학습할 때 어려움이 있었습니다.

의도된 구조인지 고민해봤지만, 테스트들이 일정한 카테고리로 분류될 수 있다고 판단했고, 카테고리화할 경우 학습 효과가 높아질 것으로 기대하여 다른 테스트와 동일하게 @Nested를 적용했습니다.

특히 goodcode 패키지는 실패하는 테스트를 통과시키는 다른 학습 테스트들과 달리, 같은 주제에 대해 단계적으로 개선되는 구조를 보여주고 있었습니다. 이러한 특성상 카테고리화가 더욱 필요하다고 판단했습니다.

잘못 파악한 부분이 있다면 피드백 부탁드립니다.

카테고리 분류

ReadableCodeTest (읽기 좋은 코드) — 5개 카테고리

카테고리 테스트 수 핵심 학습 내용
이름으로 의도 전달하기 4개 모호한 변수명 → 주석 → 의미있는 이름 → 객체 분리
일관된 코드 스타일 2개 비일관적 네이밍/포맷 → 리팩토링
메서드와 객체의 추상화 3개 거대한 메서드 → 메서드 분리 → 객체 분리
매개변수의 의미 전달 4개 순서 의존 생성자 → 주석 → 빌더 패턴 → VO 그룹화
적절한 API 활용 4개 수동 검사 → Collection API → 자료구조(Set) → 과도한 사용 경계

PredictableCodeTest (예측 가능한 코드) — 4개 카테고리

카테고리 테스트 수 핵심 학습 내용
반환값으로 상태 전달하기 4개 매직값(-1) → null → Optional → 예외
Command-Query Separation 1개 상태 변경(Command)과 조회(Query) 분리
동작을 무시하지 않기 2개 조용히 무시 → 예외로 명시적 처리
타입 안전성 5개 문자열 → 열거형 → switch 표현식 → 열거형에 행위 부여

AvoidMistakeCodeTest (실수를 방지하는 코드) — 3개 카테고리

카테고리 테스트 수 핵심 학습 내용
가변 객체의 공유 문제와 불변 객체 2개 가변 객체 공유 → 불변 객체(record)
캐싱 전략과 성능 3개 무제한 캐싱 → 범위 제한 → 적정 시점까지만 불변
방어적 복사와 불변 컬렉션 3개 외부 조작 가능 → 방어적 복사 → unmodifiableList

변경 범위

  • initial/, complete/ 양쪽 동일한 구조로 적용
  • 테스트 로직 변경 없음 (들여쓰기 + @Nested 래핑만)
  • 구조만 변경했으나 들여쓰기 때문에 변경 범위가 많은 점 양해 부탁드립니다!! 😅

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces structural improvements to the test suite by organizing test cases into nested classes for better readability and logical grouping. Additionally, a new file was incorrectly added to the tmp directory. I have provided feedback to remove this temporary file to maintain project cleanliness.

@@ -0,0 +1,490 @@
package cholog.goodcode;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

이 파일은 tmp 디렉토리와 함께 의도치 않게 추가된 것으로 보입니다. 프로젝트의 깨끗한 상태를 유지하기 위해 해당 디렉토리와 파일을 삭제하는 것이 좋겠습니다.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

수정했습니다

72d87a3

Copy link
Copy Markdown
Contributor

@jaeyeonling jaeyeonling left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR 감사함다 고생 많으셨어요!!

if (power <= 4) {
return;
@Nested
@DisplayName("Command-Query Separation")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여기 DisplayName만 영어인데, 의도된 것이 맞을까요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

넵 의도된 것 맞습니다.

한번 한글 네이밍 고민을 해봤는데, "명령-조회 분리"가 어색하다고 느껴져서 Command-Query Separation 으로 작성했습니다!

@jaeyeonling jaeyeonling merged commit 7b12092 into cho-log:main Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants