Doing the checkout kata without getters or setters
I tried doing the checkout kata using no getters nor setters at a lunchtime break at work being challenged by a senior dev. I failed miserably so, obviously, I had to do a second take at home.
This time with a lot more success after understanding I had to use message passing and not rely on objects providing the properties.
I ended up with the Test class as an Observer and the classes would talk to each other like in the beautifully drawn diagram below.
GitHub solution linked at bottom.
Resources
- Solution link: github repository
- Video explaining why we shouldn’t use getters and setters Tell, don’t ask