Effective Dictionary Usage(C#): Avoid If Statements
If you have not Medium membership, you can use the friend link to read this article.
After publishing this article, I got so many feedbacks. They claim that dictionary usage is more complicated than if usage and they claim I made mistake about performance benchmarks. Unfortunately, as I see they were right mostly :(
So that, I canceled benchmark section for now and I will make bigger change when I have time.
In this case, you can use polymorphism or some design patterns(probably it would be better for performance).
I suggest read this as an article that gives a different perspective on the usage of dictionary.
Thanks Eiad Al-khanshour, Konstantin Mi and some Reddit users for their feedbacks.
So many best practises suggest to avoid if statements
. They say thatif conditions
make more complex and buggy our applications.
Of course, conditions are a basic concept of programming. We can’t get rid of if statements completely but we can decrease its usage.
You can watch that video for more information(end of article, you can see more reading about this topic):