-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
2단계 - 문자열 덧셈 계산기 #5924
base: younghooniii
Are you sure you want to change the base?
2단계 - 문자열 덧셈 계산기 #5924
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2단계 구현 잘해주셨네요 👍
몇 가지 코멘트 남겨두었는데 확인해 주시고 다시 리뷰 요청해 주세요.
@@ -0,0 +1,42 @@ | |||
package study.step2; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
패키지명은 넘버링보다 기능명으로 작성하면 좋을 것 같아요.
|
||
public class StringAddCalculator { | ||
|
||
public static int splitAndSum(String text) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
프로그래밍 요구사항
메소드가 너무 많은 일을 하지 않도록 분리하기 위해 노력해 본다.
를 지키기 위해 메서드를 분리해 보시면 좋을 것 같아요.
if (text.startsWith("//")) { | ||
Matcher m = Pattern.compile("//(.)\n(.*)").matcher(text); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
변경되지 않는 문자열이나 패턴 객체는 상수로 선언해 이름을 부여하면 어떨까요?
try { | ||
number = Integer.parseInt(token); | ||
} catch (NumberFormatException e) { | ||
throw new RuntimeException("숫자가 아닌 값이 포함되어 있습니다: " + token); | ||
} | ||
if (number < 0) { | ||
throw new RuntimeException("음수는 허용되지 않습니다: " + number); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
문자열을 분리하기 전에 유효성을 먼저 검증하면 어떨까요?
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
public class SetTest { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
피드백이 반영되지 않은 커밋이 그대로 남아 있네요.
온라인 코드 요청 3단계 가이드 문서를 참고해서 rebase 후 피드백 반영도 함께 해주시면 좋을 것 같아요
No description provided.