(막간 보충 공부중)
“TDD 또한 큰 도움이 된다. 실패한 테스트는 당시의 흐름을 유지한다. 방해가 사라진 후 실패한 테스트가 통과하도록 일하다 보면 흐름으로 돌아갈 수 있다.”— 클린 코더 The Clean Coder, 로버트 마틴
느낀 점
오늘 저녁에 알고리즘 문제풀이 스터디 팀원들과 튜터님을 찾아갔다가 mob programming이라는 걸 경험했다. 한 문제를 한 메모장(에디터)에, 각 1분씩 돌아가며 구두로 프로그래밍을 이어가는 것이다. 관전인이 갑자기 많아져서 긴장되긴 했지만, 긴장되는 만큼 재미있었다. 내일 스터디에 도입해보기로 하였다. 당장 흥미로운 점은 크게 두 가지였다:
- 누가 시작을 하든 남이 그려놓은 청사진을 빠르게 이해하고 이어서 건물을 지어 올려야 한다.
- 손으로 쓰던 코드를 말로 읊어내야 한다.
오늘 한 일
- 프로그래머스 Lv0 피자나누기 3
- 프로그래머스 Lv 0 문자열 뒤집기
- + 프로그래머스 Lv 0 옹알이 1
- 저녁 8시에 튜터님께 찾아가 문제풀이
공부 자료 후보
(리액트 + 인수(Acceptance) TDD 테스트 ⇒ 할 일 프로그램을 인수테스트 하는데, 리액트랑 잠깐 공부해 볼 시간 있으면 봐도 좋을 것)
Test-Driven Development in JS with Acceptance Tests
🤔 This video explains why TDD is not about testing to find bugs, but instead is used to find the best technical solution. I'll discuss red-green-refactor and do live-coding to show how you can use TDD with Acceptance Tests. 🌱
Source code: https://github.com/branneman/tdd-example
0:00 Intro
0:57 Why TDD
6:48 The TDD loop
13:12 TDD with Acceptance Tests


(Mars Rover Kata와 중복 제거 리팩토링 시범)
Test-Driven Development (TDD) in JavaScript #4 - Duplication & The Rule Of Three
In this video, Jason Gorman illustrates how refactoring to remove duplication from our code can lead us to a better design, and demonstrates the Rule of Three that can guide us towards better abstractions and protect us from leaving refactoring too late.
The example used is the Mars Rover Kata https://kata-log.rocks/mars-rover-kata

궁금증
- 클래스에서 생성자로 this.value를 초기화해주지 않아도 메소드 안에서 바로 this.value를 활용(작성 및 참조)할 수 있는 이유?
class Stack { constructor() { this._size = 0; } pop() { if (!this.toBePopped) { throw new Error('Stack underflow') } const result = this.toBePopped.item; this.toBePopped = this.toBePopped.nextToBePopped; this._size--; return result; } push(item) { this.toBePopped = { item, nextToBePopped: this.toBePopped, } this._size++; } peek() { if (!this.toBePopped) { throw new Error('Stack underflow') } return this.toBePopped.item; } size() { if (!this.toBePopped) { return 0; } return this._size; } isEmpty() { return this.size() === 0; } }
- get peek(), get pop() 과 그냥 push(value). 왜 get이고 왜 set push(value)가 아닌가?
class Stack { constructor() { this.top = -1; this.items = {}; } get peek() { return this.items[this.top]; } push(value) { this.top += 1; this.items[this.top] = value; } get pop() { let item = this.items[this.top]; delete this.items[this.top]; this.top -= 1; return item; } }
Uploaded by N2T