Skip to content

Conversation

@rla6755
Copy link

@rla6755 rla6755 commented Nov 12, 2025

안녕하세요 step2 학습 테스트 실습 완료했습니다.

질문이 있습니다!

테스트 메서드에서의 public의 의미가 궁금합니다!
또한 TDD GREEN단계에서 메서드 구현 시
분기별 RETURN 값이 아닌 기본 반환값은 어떤 식으로 구현해놓는게 좋을까요?
제 생각으로는 return throw new 예외 ("구현 예정") 처리를 하는 것을 생각했는데요
다른 방식이 있는지 궁급합니다!

ex)
public static int splitAndSum(String text) {
if(StringUtils.isBlank(text)) {
return 0;
}
return 0; <<-- 이부분 입니다!
}

# Conflicts:
#	src/test/java/study/StringTest.java
Copy link
Contributor

@javajigi javajigi left a comment

Choose a reason for hiding this comment

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

바쁜 와중에도 미션 진행하느라 수고했어요. 👍
splitAndSum() 메서드가 너무 많은 책임을 담당하고 있네요.
이번 단계 연습이 메서드 분리 연습인 만큼 메서드가 한 가지 책임만 가지도록 리팩터링해보면 좋겠습니다.
"규칙 1: 한 메서드에 오직 한 단계의 들여쓰기(indent)만 한다." 원칙을 지키면 자연스럽게 메서드 분리할 수 있을 겁니다.
피드백 반영하다 방향을 찾기 힘들면 1주차 강의 동영상을 참고해 볼 것을 추천합니다.

import java.util.regex.Pattern;

public class StringAddCalculator {
public static int splitAndSum(String text) {
Copy link
Contributor

Choose a reason for hiding this comment

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

메서드가 너무 많은 책임을 가지고 있음.
메서드가 한 가지 책임만 가지도록 리팩터링해본다.
이번 단계가 메서드 분리 연습 단계인 만큼 메서드 분리 연습하기 딱 좋은 코드네요.

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