Parameterize Before Employing Polymorphic Solutions (OOP)
The following statement can be taken as axiomatic in just about all things:
“Keep it simple”
Accordingly, I wanted to create a series of classes where the only difference between them was the instanciation of a particular field to a pre-set value. I was going to employ a template pattern, when I realised that given that the difference between all the different classes lay only in the field value, one could entirely eliminate the need for a polymorphic solution and simply parameterize the class to take that field in the constructor. Duh!?
Consider the following, and consider what is simpler:
Written on January 10, 2018