What are the best options for replacing large switch statements in 2019

I am revisiting some code in a Fiddler extension. It provides validation for all sessions related to our API. The extension has what are effectively nested switch statements for matching different URLs and other criteria, and then provides suggestions for fixing the problem.

Dispatching using a dictionary or the command pattern seem like popular solutions based on different google searches. I understand that recent versions of C# also introduced pattern matching, but it’s a bit nerfed compared to what is available in F#.

Are there any other options in the newest versions of C# before I starting digging into the ones I’m familiar with?

submitted by /u/brianly
[link] [comments]

Leave a Reply