One day, I was watching another Uncle Bob’s video (yes, they are addictive), when I see one example he gave when talking about open closed principle, it ringed a bell in my head. This looked familiar! The type in some data classes, some switchs or ifs, some &&s and ||s all dancing around in the class. I can almost hear them teasing: “Come and catch me! Come and catch me!”.
Object Oriented Design
In one of Uncle Bob’s video, he talked about this game called “Master Mind” when he was teaching Single Responsibility Principle(SRP). After googled the game, turns out that it is actually a quite famous board game. For more information about the game, please look here -> wiki. The game can be played by two people. One comes up with a code, the other one tries to guess. The one who comes up with the code has to score the guesser’s guess based on some rules.
I was watching some Uncle Bob video some day which talked about how to design the architecture of a system. In that video, he gave a case study of a payroll system, I found the souce code and it is actually implemented in C++, so I ported a Java version. This is a very good example because it feels more realistic than most dummy demos out there. It also shows how to use POJO classes to layout the foundation without going too much into peripheral details like database.