How many times have you worked with inheritance hierarchy, which was almost impossible to change? Which made you feel like you are not the one in control, but just plugging bits and pieces into this big colossus? If you make living out of programming for some while, chances are you have experienced this more than once. So how do we prevent this?

We will use typical e-shop domain in examples, which you are most probably familiar with.

Where lies the problem?

Let’s model a product. Product has a name and can be priced in two ways. Either in some currency (euros in our case)

Josef Starychfojtu

Head of Backend at Mews, functional programmer, computer science, both student and teacher, @JStarychfojtu on twitter

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store