I can't help but question if the use of Discriminated Unions within a large system violates the Open/Close principle.
I understand the Open/Close Principle is Object Oriented and NOT functional. However, I have reason to believe that the same code-smell exists.
I often avoid switch statements because I am usually forced to handle cases that were not initially accounted for. Thus, I find myself having to update each reference with a new case and some relative behavior.
Thus, I still believe that Discriminated Unions have the same code-smell as switch-statements.
Are my thoughts accurate?
Why are switch statements frowned upon but Discriminated Unions are embraced?
Do we not run into the same maintenance concerns using Discriminated Unions as we do switch-statements as the codebase evolves or digresses?
Aucun commentaire:
Enregistrer un commentaire