-
Notifications
You must be signed in to change notification settings - Fork 709
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
Step3 #2027
base: kimbro97
Are you sure you want to change the base?
Step3 #2027
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.
안녕하세요 형재님, 사다리게임 3단계 미션 잘 구현해주셨어요 👍
몇가지 피드백 남겨드렸으니 확인 후 다시 리뷰요청 부탁드려요~
lines.initialize(names.size(), height, new RandomLadderPoint()); | ||
|
||
OutputView.printNames(names); | ||
OutputView.printLadders(lines); |
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.
private Names names; | ||
private Lines lines; |
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.
불변값이라면 final 키워드를 붙혀도 좋을 것 같네요
private void initialize(Height height, GenerateLadderPoint generateLadderPoint) { | ||
this.lines = createLines(height, generateLadderPoint); | ||
this.lines = lines; | ||
validateResults(results); |
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 java.util.List; | ||
import java.util.Map; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.IntStream; | ||
|
||
public class LadderGame { |
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 position; | ||
} | ||
|
||
private List<Line> createLines(int size, Height height, GenerateLadderPoint generateLadderPoint) { |
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.
사용자가 매번 new로 객체를 생성하고 초기화로직을 실행시키는 것과
정적 팩토리 함수를 활용하는것중 어떤게 좀 더 나을까요?
if (inputName.getName().equals(PARTICIPANT_NAME_ALL)) { | ||
printAllParticipantResults(ladderResults); | ||
} else { | ||
printSingleParticipantResult(inputName, ladderResults); | ||
} |
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.
view 계층이라도 if-else는 안티패턴입니다!
System.out.println(output); | ||
private static void printAllParticipantResults(LadderResults ladderResults) { | ||
ladderResults.getAllResults().forEach((participant, result) -> | ||
System.out.println(participant.getName() + " : " + result.getResult())); |
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.
StringBuilder를 활용해서 무분별한 System.out을 줄여보면 어떨까요?
new LadderResult(null); | ||
}); | ||
} | ||
} |
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.
현재 테스트를 전체적으로 확인해봤는데,
- LadderGame : 전체적으로 사용하지 않는 함수 제거 필요, private 함수들에 대한 테스트 없음(private 함수를 직접 호출하라는게 아니라 public함수에서 분기검증이 되지 않았다는 의미입니다. )
- LadderResult( with LadderResults): 일급 컬렉션 생성자 테스트 및 사다리 결과 조회 테스트 부족
- Line : 전체적으로 테스트 부족
- Lines: getter와 move에 대한 테스트 부족
- Name, Names: getter 테스트 및 불필요 함수 존재
TDD인만큼 테스트에 좀 더 신경써보는건 어떨까요?
|
||
class LadderResultTest { | ||
@Test | ||
@DisplayName("결과가 입력되지않으면 예외가 발생한다") |
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.
예외는 발생한다기보단 던져지는게(throw) 적절한 표현입니다.
리뷰 요청드립니다 !!