-
Notifications
You must be signed in to change notification settings - Fork 212
[자동차 경주] 유아름 미션 제출합니다. #188
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
Open
yooaknow
wants to merge
32
commits into
woowacourse-precourse:main
Choose a base branch
from
yooaknow:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
함수 분해에 관한 Tempero(2024)의 연구 내용을 정리한 섹션을 추 가함.
@woowacourse/mission-utils 패키지를 설치하고 jest 테스트 환경과 실행 스크립트를 설정했습니다.
package.json의 description 필드에 잘못 입력된 README 내용 일부를 제거했습니다. 프로젝트 설명을 간결하게 '우테코 자동차 경주 게임 과제용 프로젝트'로 수정했습니다.
자동차 이름과 시도 횟수를 입력받는 기능을 구현했습니다
구현 체크리스트의 자동차 이름과 시도 횟수 입력 관련 기능을 체크 상태로 변경했습니다.
자동차 이름은 공백 제거 후 1~5자를 허용하며, 시도 횟수는 1 이상의 정수만 허용합니다. 이를 만족하지 못하면 에러를 발생시키도록 구현했습니다
각 이름의 길이와 시도 횟수가 1 이상인 지 등 검증 관련 단계를 체크 상태로 변경했습니다.
0~9사이의 난수에서 4 이상일 때 전진하도록 코드를 구현했습니다
매 시도마다 랜덤 값을 생성하고, 4 이상이면 전진하도록 구현했습니다.
실행 결과 헤더, 라운드별 상태, 최종 우승자 출력하는 기능을을 추가했습니다.
차수별 실행과 우승자가 출력되도록 구현했습니다.
입력, 검증, 경주, 출력 모듈을 통합하여 전체 실행 흐름을 구성했습니다
중복 catch/ 불필요 throw 제거 및 export default App을 추가 했습니다.
'Cannot find module ./output.js' 오류 해결
변수 대소문자 오류로 인한 ReferenceError 수정
콜론 앞뒤에 공백을 맞춰 테스트 형태와 동일하게 변경했습니다.
최종적으로 테스트가 돌아감을 확인했습니다
playRound 함수에서 3항 연산자를 제거했습니다.
MDN 문서를 참고하여 공부하고, 쓰지 않는 것이 좋은 이유를 작성했습니다.
'(이름은 쉼표...) 부분 앞 공백을 제거하여 형식을 맞춰주었습니다.
Random 호출을 외부 주입 방식으로 변경하여 함수의 단일 책임 원칙을 강화하였습니다.
race.js 에서 랜덤 생성과 이동 규칙이 한 함수에 섞여있었습니다. 해당 로직을 분리한 이유를 문서에 기록했습니다.
Jest를 이용해 shouldMove, playRound, playAllRounds 기능 검증
자동차 이름과 시도 횟수 유효성 검증 로직 테스트 추가
개발자, 설계자, 기획자로서 생각을 적어보았습니다.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
구현 요약
이번 과제는 "큰 함수를 단일 역할을 수행하는 작은 함수로 분리" 하는 것이 핵심 목표였습니다.
처음에는 단순히 함수를 작게 쪼개면 된다고 생각했지만, 실제 구현 과정에서
어디까지 분리하고, 어디서 응집해야 하는지가 익숙하지 않아 어려움을 느꼈습니다.
이에 따라 함수 분해의 이해도를 다룬 Tempero, E., Denny, P., Finnie-Ansley, J., Luxton-Reilly, A., et al. (2024) 을 참고했습니다.
논문 결과에 따르면
이 연구를 바탕으로 이번 구현에서는 다음 기준으로 구조를 설계했습니다.
디렉토리 구조
질문
이런 식으로 '로직의 성격(절차형 vs 분기형)'을 기준으로 함수 분해 방향을 정한 접근이 올바른 방향인지 궁금합니다. 혹시 더 나은 판단 기준이나, 함수 분리 관점이 따로 있을까요?
더 자세한 구현 배경과 회고는 README 를 참고해주세요! 감사합니다. 📄