5
shouts

Invoking methods based on a parameter without if-else statements in C#

published 78 days, 4 hours, 35 minutes ago posted by http://webpoet.myopenid.com/http://webpoet.myopenid.com/ 78 days, 8 hours, 57 minutes ago
Tuesday, November 24, 2009 2:04:10 AM GMT Monday, November 23, 2009 9:42:23 PM GMT

Today I found myself using a switch statement to determine which method to invoke depending on the value of a variable. The code looked messy and wasn't very flexible. The fix was to use a dictionary with delegates.

category: Architecture | clicked: 38 | | source: joelabrahamsson.com | show counter code
tags: C#