-
Notifications
You must be signed in to change notification settings - Fork 227
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
Step1 - 문자열 덧셈 계산기 #815
Step1 - 문자열 덧셈 계산기 #815
Conversation
이전 커밋 이력과 함께 미션이 수행되었네요. 미션 수행을 위한 STEP을 확인해서 진행하시면 좋을 것 같아요~! 😄 |
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.
안녕하세요~! 준형님,
이번 미션을 잘 진행해주셨네요~! 👍
몇가지 코멘트를 남겼으니 확인주세요!!
고생하셨습니다~! 😄
String delimiter = "[,:]"; | ||
String numbers = text; | ||
|
||
Matcher matcher = 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.
Pattern을 캐싱해보면 어떨까요?
고정적이면서 생성 비용이 많이 드는 항목은 사전에 생성해둔다면 성능상 이점을 가져갈 수 있겠네요~! 😄
if (number < 0) { | ||
throw new RuntimeException("Negative numbers are not allowed: " + 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.
0 미만에 대한 책임을 분리하기 위하여 VO를 활용해보면 어떨까요?
|
||
return sum; | ||
} | ||
} |
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.
마지막은 개행으로 끝날 수 있도록 설정해보면 어떨까요~!?
4d5f0a3
to
bd262f8
Compare
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.
안녕하세요~! 준형님,
피드백 잘 반영해주셨네요. 👍
추가 코멘트를 남겼는데 코멘트와 관련하여 궁금하신 점은 DM을 남겨주세요~! 😄
assertThatExceptionOfType(RuntimeException.class) | ||
.isThrownBy(() -> calculator.add("-1")); | ||
} | ||
} |
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.
마지막 라인에 개행이 추가안된 부분들이 있네요~!
int number = Integer.parseInt(token); | ||
if (number < 0) { | ||
throw new RuntimeException("Negative numbers are not allowed: " + 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.
Number라는 VO를 통해서 숫자를 관리해보면 어떨까요~!?
궁금하신 점은 DM으로 남겨주셔도 됩니다~! 😄
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.
VO 로 만들어 넣겠습니다.
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.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.AssertionsForClassTypes.assertThatExceptionOfType; | ||
|
||
class StringCalculatorTest { |
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.
Number에 대한 TestCode를 분리해서 만들어보면 어떨까요~!? 😄
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.
테스트 코드를 분리 하겠습니다~
@@ -0,0 +1,16 @@ | |||
package StringCalculator; | |||
|
|||
public class 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.
Number 잘 만드셨네요~! 👍
String[] tokens = numbers.split(delimiter); | ||
int sum = 0; | ||
for (String token : tokens) { | ||
Number number = new Number(token); | ||
sum += number.getValue(); | ||
} | ||
|
||
return sum; |
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.
일급컬렉션을 활용하여 작성해보면 어떨까요~!?
합산에 대한 책임 명확하게 분리될 것 같아요~!
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.
일급 컬렉션을 만들어 분리 하였습니다.
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.
안녕하세요~! 준형님,
피드백 잘 반영해 주셨네요~! 👍
다음 미션을 위해서 Merge하겠습니다.
고생하셨습니다~! 😄
assertThatExceptionOfType(RuntimeException.class) | ||
.isThrownBy(() -> new Number("-1")); | ||
} | ||
} |
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.
개행은 설정만 잡는다면 이후부터 신경쓸 포인트가 줄어들어요~! 😄
JUnit 5 학습 을 step 1 으로 브런치를 따서 이번 문자열 덧셈 계산기를 1-1로 만들어 푸시했습니다.
문자열 덧셈 계산기를 만들었습니다. 리뷰 부탁 드립니다.