[자동차 경주] 홍상우 미션 제출합니다.#204
Open
Dev-SangWoo wants to merge 7 commits intowoowacourse-precourse:mainfrom
Open
Conversation
Author
|
이번 시간에 처음으로 테스트 코드라는 걸 짜보고, jest 를 사용해보면서 협업을 하는 과정에 있어 얼마나 객관적이고 논리적으로 코드를 짜야하고, 모두가 일관된 코드를 작성하기 위해서 필수적으로 테스트 도구를 사용해야겠다고 깨달음을 얻었습니다. 또 그저 말로만 듣던 TDD(테스트 주도 개발)은 어떻게 하는지 대략적인 느낌을 얻을 수 있었습니다. 테스트 도구 뿐만 아니라 함수를 작게 쪼개는 것도 굉장히 인상 깊었습니다. 들여쓰기가 2번을 넘으면 안되니까 나중엔 함수로 기능들을 더욱 세분화해서 작업을 진행했습니다. 들여쓰기가 심한 형태는 사람이 읽기 복잡해지고, 결국 사람도 이해해야 하기에 가독성 좋은 코드, 의미 있는 변수 명, 함수형 스타일의 코드 작성 등이 필요하겠다고 생각했고, 그저 은연중에 알고 있었던 개념들이 왜 필요한지 알 수 있는 시간이었습니다. 또한 의존성 주입이라던지, 또 랜덤으로 얻는 값은 테스트에서는 통제해야하니까 가짜 목업함수를 만들어서 통제한다던지 같은 실제 업무에 기초 배경들을 접할 수 있어서 매우 재미있었던 시간인 것 같습니다. |
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
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.
javascript-racingcar-precourse
자동차 이름 처리
[Input] 사용자에게 경주할 자동차 이름 입력을 받는다.
[Logic] 입력받은 문자열을 쉼표(,) 기준으로 분리한다. (e.g., "pobi,woni,jun" -> ['pobi', 'woni', 'jun'])
[Logic] 분리된 이름 배열이 5자 이하 등 유효한지 검사한다. ([ERROR] 발생)
시도 횟수 처리
[Input] 사용자에게 시도할 횟수 입력을 받는다. (App.js의 run 담당)
[Logic] 입력받은 횟수가 1 이상의 숫자인지 검사한다. ([ERROR] 발생)
경주 진행
[Data] 자동차 이름 목록으로 자동차 객체(또는 클래스) 목록을 생성한다. (e.g., [{ name: 'pobi', position: 0 }, ...])
[Logic] 자동차 한 대가 무작위 값(0~9)을 받아 4 이상일 경우 전진하는 기능을 구현한다.
(Random.pickNumberInRange가 4를 반환할 때, 3을 반환할 때를 각각 테스트)
[Logic] 모든 자동차에 대해 1라운드(1회 시도)를 실행한다.
[Output] 1라운드(차수)별 실행 결과를 형식에 맞게 출력한다. (e.g., pobi : -)
최종 결과
[Logic] 경주가 끝난 후, 가장 멀리 간 우승자를 찾는 기능.
(e.g., [{ name: 'pobi', position: 3 }, { name: 'woni', position: 5 }]을 넣으면 'woni'가 나오는지 테스트)
[Output] 최종 우승자를 형식에 맞게 출력한다. (공동 우승자 쉼표 구분)