Hi!, I
t looks to me that creating and using the array $calculators to define the different calculators is breaking the Open-Closed principle itself since we would have to modify it if we add future calculators.
With the dinamically class creation this does not happen, but I am wondering if there is not another way to do it, though this one seems more correct indeed.
Thanks!
Interesting point. To be honest, after shooting this course and trying to implement it in practice, I realize more and more that these principles are more THEORETICAL and sometimes breaking them is ok. So if using the array $calculators is actually making problems to your code maintainability in the future, then sure, refactor it in another way you prefer.
Hi!, I t looks to me that creating and using the array $calculators to define the different calculators is breaking the Open-Closed principle itself since we would have to modify it if we add future calculators. With the dinamically class creation this does not happen, but I am wondering if there is not another way to do it, though this one seems more correct indeed. Thanks!
Interesting point. To be honest, after shooting this course and trying to implement it in practice, I realize more and more that these principles are more THEORETICAL and sometimes breaking them is ok. So if using the array $calculators is actually making problems to your code maintainability in the future, then sure, refactor it in another way you prefer.