-
Notifications
You must be signed in to change notification settings - Fork 212
[자동차 경주] 권세빈 미션 제출합니다. #192
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
base: main
Are you sure you want to change the base?
Conversation
- 기능 요구사항 문서화 - 구현할 기능 목록 7개 카테고리로 분류 - 프로젝트 구조 설계 - 프로그래밍 요구사항 정리
- Console API를 활용한 사용자 입력 처리 - 자동차 이름 입력 및 파싱 - 시도 횟수 입력 및 변환 - 쉼표 구분 및 공백 제거 처리
- Console API를 활용한 결과 출력 - 라운드별 자동차 상태 출력 - 자동차 위치를 '-' 문자로 시각화 - 최종 우승자 출력 (단독/공동)
- 게임 전체 흐름 제어 - InputView를 통한 입력 처리 - InputValidator를 통한 유효성 검증 - Random API를 활용한 무작위 값 생성 - OutputView를 통한 결과 출력
- App 클래스로 애플리케이션 시작 - index.js 진입점 생성 - GameController 연동
zzzRYT
left a comment
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.
2주차 고생하셨습니다! 코멘트에 언급하긴 했지만, Controller 부분을 사용하는게 인상깊었습니다. 저도 다음 주차에서는 고려해봐야겠어요!💪
| test('최대 위치를 가진 자동차들을 찾는다 - 단독 우승자', () => { | ||
| const cars = new Cars(['pobi', 'woni', 'jun']); | ||
|
|
||
| cars.moveAll([5, 4, 3]); | ||
| cars.moveAll([6, 3, 2]); | ||
|
|
||
| const winners = cars.getWinners(); | ||
|
|
||
| expect(winners).toHaveLength(1); | ||
| expect(winners[0].getName()).toBe('pobi'); | ||
| }); | ||
|
|
||
| test('최대 위치를 가진 자동차들을 찾는다 - 공동 우승자', () => { | ||
| const cars = new Cars(['pobi', 'woni', 'jun']); | ||
|
|
||
| cars.moveAll([5, 6, 3]); | ||
| cars.moveAll([6, 5, 2]); | ||
|
|
||
| const winners = cars.getWinners(); | ||
|
|
||
| expect(winners).toHaveLength(2); | ||
| expect(winners.map(car => car.getName())).toEqual(expect.arrayContaining(['pobi', 'woni'])); | ||
| }); | ||
|
|
||
| test('모든 자동차가 같은 위치면 모두 우승자다', () => { | ||
| const cars = new Cars(['pobi', 'woni', 'jun']); | ||
|
|
||
| cars.moveAll([3, 3, 3]); | ||
|
|
||
| const winners = cars.getWinners(); | ||
|
|
||
| expect(winners).toHaveLength(3); | ||
| }); | ||
| }); No newline at end of file |
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개의 테스트의 경우에는 test.each로 한 번에 처리가 가능할 것 같습니다!
우테코에서 알려준 블로그
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.
제 코드를 기준으로 생각했을 때, App에서 실행에 대한 역할을 수행하고 있습니다. 저도 App에서 사용하는 여러가지 로직들에 대한 책임을 관리해줄 중간 관리자가 있으면 좋겠다고 생각했는데, 해당 코드를 보고 고민해봐야 겠네요ㅎㅎ 잘봤습니다!😁
| move(randomValue) { | ||
| if (randomValue >= 4) { | ||
| this.#position += 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.
제 코드에서도 적용하지 못한 부분이긴한데, 이 코드를 문득 든 생각입니다. 정확하지 않을 수 있으니 참고하세요😅
Car에서는 오로지 움직일 수 있는 역할만 수행한다면, 랜덤값이 4이상 일 때라는 조건을 Game쪽으로 책임을 넘기고 오로지 움직임만을 위한 로직을 만들어도 괜찮을 것 같네요
이렇게 생각한 이유가, 만약 게임에 대한 룰이 바뀌었을 경우, Game에서도 바꿔야겠지만, Car에서도 랜덤값이 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.
개인적인 생각이긴하지만, 검증 로직의 경우에 범용적으로 사용되는 검증이 아니라면, 사용되는 부분과 함께 관리되는게 좋다고 생각합니다. 그래야 변경사항이 생겼을 때, 유지보수하기 편하더라구요
예를들어서, validation이라는 폴더에 하위 파일로 carValidation,inputValidation과 같이 나눈다거나, 그냥 사용하는 파일 옆에 같이 붙여둔다던가. 그럴 것 같습니다!😎
lee-eojin
left a comment
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.
안녕하세요! 2주차도 수고하셨습니다! 객체지향 설계 원칙을 잘 적용하신 것 같습니다.
특히 Validator가 Controller와 완전히 분리되어 있는 설계가 인상적이었습니다.
테스트 케이스가 다양해서 재밌게 공부했습니다.
| import App from './App.js'; | ||
|
|
||
| const app = new App(); | ||
| await app.run(); | ||
| app.run(); |
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.
App.run()이 async 메서드라서, 원본 템플릿에는 await이 붙어있었던 것 같습니다.
혹시 await을 제거하신 특별한 이유가 있으실까요? 궁금합니다!
🏎️ 자동차 경주 게임
🎯 구현 완료 사항
기능 요구사항 ✅
[ERROR]발생프로그래밍 요구사항 ✅
@woowacourse/mission-utils사용📂 프로젝트 구조
🧪 테스트 결과
💡 주요 구현 내용
1. TDD 방식 적용
2. 객체지향 설계
3. 코드 품질
#) 사용으로 캡슐화🔍 핵심 로직
Car 클래스
Cars 클래스 - 우승자 결정
InputValidator - 검증 분리
🤔 아쉬운 점
커밋 히스토리
미리 다른 파일에서 전체 구현을 완료한 후, 파일을 하나씩 옮기면서 커밋하는 방식으로 진행했습니다. 그 결과:
문제점:
개선 방향:
📝 배운 점