I’m often faced with a choice between:
1. Adding a constructor argument that accepts a lambda
2. Making the class abstract and adding an abstract function
Are there any clear advantages of one over the other? Note: the class does not otherwise need to be subclassed.
n
Nir
09/06/2020, 3:53 AM
In the latter case won't you need a concrete derived class?
Nir
09/06/2020, 3:53 AM
I'd say that 1 is significantly better, regardless
Nir
09/06/2020, 3:53 AM
Not knowing other details
Nir
09/06/2020, 3:54 AM
Classes are typically constructed once, used many times. The first only complicates the construction site. The second however complicates understanding its usage
m
Mark
09/06/2020, 8:56 AM
So perhaps abstract functions only need to be considered when polymorphism is truly required. i.e. not when you only require the instantiator to fill in some functionality.