I have recently had the pleasure to observe a code that is essentially kilometers of very deep if-else statements. The code is continuously being updated, and keeping track of the possible outcomes and their interactions is becoming progressively harder. It feels like one can do better.
I have had an idea of maybe separating the if-tree into one file, and outcomes into another. Perhaps one could even construct a matrix, where every row would be an outcome, and every possible question one might ask would be a column. Then one could do some basic logical operations on such a matrix to automatically determine if a newly added branch interferes with already existing ones.
I'm aware this idea is very vague, but I am sure somebody must have thought about optimizing if-else trees in terms of human design and edit time.
Are there any industry standards for dealing with deep if-else trees in an efficient way? If yes, I would appreciate names and links
In this particular case, I am talking about C#, but I am also interested how the problem is addressed in general
Aucun commentaire:
Enregistrer un commentaire