5
shouts

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

published 115 days, 15 hours, 41 minutes ago posted by http://webpoet.myopenid.com/http://webpoet.myopenid.com/ 115 days, 20 hours, 3 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#