-
Notifications
You must be signed in to change notification settings - Fork 43
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
[4기] [3번 과제] Wordle 과제 제출 - MUTO #16
base: main
Are you sure you want to change the base?
Conversation
- 디렉토리 경로에서 파일을 읽어와 문자열 list로 반환하는 기능 구현.
- 파일에서 요구사항 로직에 해당하는 단어를 가져오는 기능 구현.
- getWordList(): public -> private
- Answer -> Word
- 테스트 wordPath 전역변수처리 - 이름 직관적으로 변경 - 생성자 필요없는 값 노출 제거
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 (isCorrect()) { | ||
break; | ||
} |
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.
이번 미션에서는 depth가 3까지 허용이여서 이 부분도 허용되지만 메서드를 분리하는 방식으로 depth가 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.
제가 봤을때 depth2 인것같은데 아닐까요?
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.
아아 제가 잘못 말했네요 depth가 2까지 허용인데 이번 미션에서는 1까지로 해보는건 어떨까요?
src/main/java/controller/Game.java
Outdated
private void validateInput(String inputString) { | ||
inputValidator.validateEnglish(inputString); | ||
inputValidator.validateLength(inputString); | ||
} |
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.
사용자의 input 값을 validate를 통해서 확인 후 Word로 생성해주는 로직인데 이 부분은 관점에 따라서 다를거 같아요 이미 Word 객체와 Letter 객체가 이 역할 대신 해주고 있는데 따로 input에서 확인한 이유가 궁금합니다 🤔
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.
저도 코드를 작성하면서 생각을 했던 부분인데
한군데서 validate을 하는것보다 모든 객체 각각에서 validate을 한번 더 작성해주는게 좋을것 같아서 중복 작성했습니다.
코드가 많아지다보면 중간에 값이 변경되면서 문제가 생길수도 있으니까요.
그런데 생각해보니 final 키워드를 사용해서 불변으로 값을 유지하면 validate 한번으로 충분하겠네요.
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.time.LocalDate; | ||
|
||
public class Game { | ||
private static final String FILE_PATH = "src/main/resources/words.txt"; |
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.
정답 단어들이 들어있는 파일 경로가 컨트롤러에 상수로 선언되어 있는데 보통 스프링을 쓴다면 yml에 입력하거나 Config 파일로 선언하는 편인데 이 부분은 어떻게 생각하시나요?
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.
PATH등 설정값이 모여있는 Config 클래스를 따로 만들어 관리할까 생각도 했었지만 해당 관련값이 한개밖에 없어서 따로 만들지 않았습니다.
src/main/java/domain/Answer.java
Outdated
private MatchStatus match(Letter letter) { | ||
if (!answerWord.contains(letter)) { | ||
return MatchStatus.GRAY; | ||
} | ||
if (letter.equals(answerWord.get(letter.getPosition()))) { | ||
return MatchStatus.GREEN; | ||
} | ||
return MatchStatus.YELLOW; | ||
} |
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.
기능 요구사항에 "두 개의 동일한 문자를 입력하고 그중 하나가 회색으로 표시되면 해당 문자 중 하나만 최종 단어에 나타난다." 라는 요구사항이 존재하는데 제가 이해하기론 이미 한번 소모된 단어의 경우 다시 사용하지 않는다로 이해했습니다.
예를들어 오늘 정답 값이 deapt인데 eeapt인 경우 회색 1, 초록 4개로 나와야하는거죠. 현재는 노란 1개 초록 4개로 나오고 있습니다.
제가 생각한 관점과는 조금 다른데 어떻게 생각하시나요?
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.
제가 생각한 관점이 맞다면 Letter에 사용된 position 값이 사라질거 같습니다 :)
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.
position 값은 사라졌는데... 이게 테스트를 통과하는 코드를 만들지를 못하겠네여 ㅠㅠ...
src/main/java/domain/Word.java
Outdated
// public List<MatchStatus> compare(Word userInputWord) { | ||
// } |
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.
주석은 항상 삭제하고 커밋해야하는데... 감사합니다.
private static final String NO_WORD_FILE = "src/test/resources/noFile.txt"; | ||
private static final String TEN_WORDS = "src/test/resources/test10words.txt"; | ||
private static final String EMPTY_WORDS = "src/test/resources/testEmptyWords.txt"; |
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 String getAnswer(LocalDate currentDate) { | ||
Period period = Period.between(criteriaDate, currentDate); | ||
int days = period.getDays(); | ||
return words.get(days % words.size()); | ||
} |
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.
코드의 유연함을 위해서 오늘 날짜를 함수 내부에서 now로 가져오는 것이 아니라 매개변수로 받는거 너무 좋네요. 👏
public boolean validateEnglish(String input) { | ||
Matcher matcher = ENGLISH_PATTERN.matcher(input); | ||
return matcher.matches(); | ||
} | ||
|
||
public boolean validateLength(String input) { | ||
String trim = input.trim(); | ||
return trim.length() == INPUT_WORD_LENGTH; | ||
} |
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.
공백을 trim으로 처리해주셨는데 공백 값이 있는 경우엔 이미 validateEnglish 메서드에서 처리가 될거같은데 길이만 체크해줘도 문제 없을거 같습니다.
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 enum MatchStatus { | ||
GRAY("⬜"), | ||
YELLOW("\uD83D\uDFE8"), | ||
GREEN("\uD83D\uDFE9"); |
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.
타일을 enum으로 설계한 부분 좋네요 👍
|
||
public class Result { | ||
|
||
private static final int RESULT_SIZE = 5; |
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.
해당 상수인 5는 InputValidator.INPUT_WORD_LENGTH에 같은 값으로 상수 선언되어있는데 공통으로 사용할 수 있다면 좋을거 같은데 어떻게 생각하시나요?
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.
제생각엔 Result와 관련된 값이기 때문에 내부에서만 사용되어야한다고 생각하는데 공통으로 사용해야 할 이유가 있을까요?
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.
공통된 상수 5라고 생각했기 때문에 제안드렸었는데 사실 값이 같더라도 사용하는 목적이 다르기 때문에 공통으로 사용되지 않아도 될거 같네요 😊
(MUTO, 윤백) 의 페어프로그래밍 과제 제출합니다.