Trying to convince my team to give up on if/then/else & case…
Let’s play with some code!
First the the non Object Oriented / procedural version:
Finally the Object Oriented version:
I know it looks complicated, but imagine you want to add a new functionality. Let’s for example add a path to the HTTP url:
It does not violate the open/closed principle, which states:
“software entities should be open for extension, but closed for modification”.