-
Notifications
You must be signed in to change notification settings - Fork 1k
[BE 이연호] 1주차 과제 제출합니다. #1111
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
Open
Timothy-Y-H-Lee
wants to merge
14
commits into
woowacourse-precourse:main
Choose a base branch
from
Timothy-Y-H-Lee:Timothy-Y-H-Lee
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+368
−1
Open
[BE 이연호] 1주차 과제 제출합니다. #1111
Changes from 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a89c03b
docs: draft functional requirements and feature list after problem an…
9265e19
feat(#1): MVC & TDD - 모델에 사용자의 입력값을 저장
7f2a83c
docs(#2): update feature list
61ccb3c
feat(#2): Service를 이용해서 모델에 사용자의 입력값을 저장
ca9d2a3
feat(#2): Service를 이용해서 모델에 사용자의 입력값을 저장
29305db
docs(#2): 기능목록 업데이트
c22f736
refactor(#2): CalculatorService의 패키지 위치 변경
9058fef
feat(#2): MVC 구조 완성
76acd14
docs(#2): 기능 목록 업데이트: 입력값이 양수만 입력이 가능하도록 테스트 케이스 처리
b06d9df
feat(#2): 입력값이 양수만 입력이 가능하도록 테스트 케이스 처리
28244ef
docs(#2): 기능목록 업데이트 - 사용자의 입력값에서 기본 구분자와 커스텀 구분자를 함께 사용이 가능하도록 테스트 케이…
2d19816
feat(#2): 사용자의 입력값에서 기본 구분자와 커스텀 구분자를 함께 사용이 가능하도록 테스트 케이스 처리
ad712de
docs(#2): 기능목록 업데이트: 실질적으로 Model을 사용해서 구분자로 정리된 숫자 목록을 저장 후, 꺼내어 사용
fa4117b
feat(#2): 실질적으로 Model을 사용해서 구분자로 정리된 숫자 목록을 저장 후, 꺼내어 사용
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,9 +79,22 @@ public static Integer calculateSumOfNumbers(String userInput) { | |
| public static List<String> splitByDelimiter(String userInput, String delimiter) { | ||
| return Arrays.stream(userInput.split(delimiter)) | ||
| .map(String::trim) // 공백 제거 | ||
| .peek(CalculatorService::validateNumber) // 숫자 유효성 검사 | ||
| .collect(Collectors.toList()); // 리스트로 변환 | ||
| } | ||
|
|
||
| // 숫자 유효성 검사: 숫자가 아니거나 음수인 경우 예외 발생 | ||
| public static void validateNumber(String validateNumber) { | ||
| try { | ||
| Integer number = Integer.parseInt(validateNumber); | ||
| if (number < 0) { | ||
| throw new IllegalArgumentException("양수만 입력 가능합니다." + validateNumber); | ||
| } | ||
| } catch (NumberFormatException e) { | ||
| throw new IllegalArgumentException("숫자가 아닙니다. " + validateNumber); | ||
| } | ||
| } | ||
|
|
||
|
Comment on lines
+82
to
+93
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사용자에게 입력을 받는 부분은 enum을 사용해서 처리를 해주셨던 거 같은데, 예외를 던지는 메시지 같은 경우도 상수로 처리하거나 enum을 사용하는 건 어땠을까요? 개인적으로는 통일성있는 코드 구조를 선호하다보니 읽다가 궁금증이 생겼습니다. 의도하신게 있으실까요? |
||
| private static class InnerCalculatorService { | ||
|
|
||
| private static final CalculatorService INSTANCE = new CalculatorService(); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
제가 알기론
stream의peek은 디버깅을 사용할 때 유용하게 쓰는 메서드로 알고 있습니다.현재처럼 중요한 검증 로직을 peek 안에 넣게 되면 의도가 잘 드러나지 않아,
나중에 코드를 읽을 때 혼동을 줄 수 있을 것 같습니다.
오히려 validate와 같이 중요한 로직을 검증하는 것이라면, 중간에 빼서 따로 사용하는게 더 좋지 않았을까 하는 생각이 듭니다.