-
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. test 통과 #837
base: lim-devv
Are you sure you want to change the base?
step1. test 통과 #837
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.
지영님 안녕하세요 😄
미션 고생하셨습니다!
코멘트 드렸는데 확인부탁드려요!
궁금하신 내용이 있다면 언제든 DM, PR 편한 채널로 연락주세요
public StringCalculator() { | ||
} |
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.
기본생성자를 추가해주신 의도가 있을까요? 🤔
} | ||
|
||
Matcher matcher = Pattern.compile("//(.)\n(.*)").matcher(text); | ||
String separator = ",|:"; // 기본 구분자 |
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.
주석으로 표현하기 보다는 상수로 의미를 부여해보면 어떨까요?
return 0; | ||
} | ||
|
||
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
은 생성비용이 매우 비싸요. 😢
매번 생성하는 것보다 재활용을 해보는 것은 어떨까요?
separator = Pattern.quote(matcher.group(1)); | ||
text = matcher.group(2); |
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.
1,2 또한 비즈니스적으로 의미가 있는 것으로 보여요.
여기도 의미를 부여해보면 어떨까요?
@ParameterizedTest | ||
@ValueSource(strings = {"1"}) | ||
void oneNumber(final String text) { | ||
assertThat(calculator.add(text)).isSameAs(Integer.parseInt(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.
저는 테스트코드에서 검증할때 하드코딩을 선호해요.
아래 링크도 참고해보시면 좋을 것 같아요.
https://jojoldu.tistory.com/615
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
public class StringCalculator { |
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.
현재 StringCalculator
가 매우 많은 역할을 하고 있는 것으로 보여져요. 😢
클래스를 분리해서 각각 객체간의 역함을 위임하여 객체간의 협력으로 문제를 풀어보면 어떨까요?
안녕하세요 !
너무 늦었네요,, 잘 부탁드립니다 !