I've heard people saying that good design involves using inheritance instead of littering your code with if block. In what situation should we use inheritance, and when condition block is just fine?
One refactoring like this is called Replace Conditional With Polymorphism.
We actually favor composition over inheritance, but ... it's really too broad of a topic to discuss here, however the book is worth a read and can get you started.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With