banjjoknim / java-lotto-game Goto Github PK
View Code? Open in Web Editor NEW로또 게임
로또 게임
랜덤 값을 생성하는 이 로직을 다른 클래스로 분리해보는건 어떨까요?
지금 LottoNumber - generateRandomNumber()
-> Lotto - generateLottoNumbers()
-> Lottos ->generateLottos
로 이어지는데 이는 모두 테스트하기 어려운 Random 요소에 의존
하고 있다는 것입니다.
당연하게도 테스트가 없거나 혹은 있더라도 값을 제어할 수없어서 빈약한 테스트 코드를 작성할 수 밖에 없을거라고 추측합니다.
(ex. 값이 0~ 45 사이의 값인지 확인한다거나 길이나 사이즈가 6이라거나 etc..)
테스트하기 힘든 코드를 최대한 밖으로
꺼냄으로써 테스트할 수 있는 영역을 확보해가려고 하는데, 사실 이전에도 언급했던 적이 있는데 조금 어려워하셨던 기억이나네요 (어려운 내용 맞습니다)😂 어떻게 전달할지 고민해보다가 좋은 영상이나 자료를 전달드리는게 가장 빠른 길이다 싶어서 아래에 좋은 참고자료들을 가져왔습니다!
앞에서 언급한 테스트하기 힘든 코드를 최대한 밖으로 꺼내서 테스트할 수 있는 영역을 확보해나간다
라는 표현이 와닿으셨으면 좋겠네요.
일단 제가 의도하는 방향은 최종적으로 Lottos를 생성하는 핵심 기능을 외부로 분리하게 하려는 것입니다.
먼저 이 의도를 먼저 머릿속으로 생각하시면서 참고자료를 보시면 좋을 것 같아요!
잘 모르겠다면 코멘트에 추가 질문 남겨주세요 ~
[참고자료]
용근님의 발표 내용이 개인적으로 쉽게 와닿았던 것 같아서 이 내용을 참고해보면 이해에 도움이 되실 것 같아요! 제가 전달하고자 하는 내용은 2번째 주제(테스트 가능한 것, 불가능한 것)
인데 해당 내용만 보셔도 됩니다만 다른 내용도 관심이 있다면 쭉 보셔도 상관없어요~
Originally posted by @Rok93 in #2 (comment)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.