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.
기존에는 Spy 객체를 활용하여 테스트를 작성하려 했지만, Game 클래스의 생성자가 carNames를 받고 내부에서 cars를 선언하는 구조 때문에 한계를 마주했습니다. 그러다 Car들의 위치 반환이 꼭 Game에서 이루어져야 할까? 라는 고민을 하게 되었고, 이를 해결하기 위해 생성자에서 Cars를 받는 CarGroup 클래스를 도입했습니다. 이를 통해 기존의 Spy 객체 방식으로도 테스트를 처리할 수 있게 수정하였습니다.
그런데 주변분들이 미션을 진행하는 것을 살펴보니 저만 Spy 객체를 활용하고 있었고, 다른 방법이 있을까 찾아보던 중 NumberProvider 인터페이스를 활용하여 다형성으로 해결하는 방식을 발견했습니다. 이 방식이 흥미로워보였고, 이를 적용해보기 위해 Spy 객체를 사용하지 않는 방향으로 구현했습니다. 또한, MVC 패턴 기반으로 리팩터링하면서 view 패키지가 domain 패키지 객체에 의존할 수 있지만, domain 패키지 객체가 view 패키지에 의존하지 않도록 구현해야 한다는 점이 흥미로웠습니다. 다행히 3단계에서 이미 4단계를 일부 적용한 상태였기 때문에, 불필요한 의존성을 줄이는 작업만 진행하며 마무리할 수 있었습니다. 딱히 궁금한게 떠오르지는 않고, 어떤 방향으로 더 개선할 수 있을지만 궁금하네요
(하지만 역시 단위테스트 작성할때 Spy객체 활용하는게 좋은 것 같아요. ex. 기존 객체의 상태를 유지하면서 특정 메소드가 정확히 몇 번 호출되었는지 검증 가능)