10
Shouts

Refactor Switch to Dictionary

published 1243 days, 15 hours, 15 minutes ago posted by KodefuGuruKodefuGuru 1246 days, 6 hours, 38 minutes ago
Saturday, January 23, 2010 11:16:12 AM GMT Wednesday, January 20, 2010 7:52:52 PM GMT

In my post on Z3, I created an extension method for proving an equation. This extension method used a switch statement to analyze a result and return a string. This is a bad practice: the mapping of one type to another is trapped in code. What if I wanted to move this mapping to a configuration file, a resource file, or a database? Even if I didn’t want to do that, I feel an imperative switch statement isn’t as readable as a declarative statement. Favor Declarative over Imperative. Below is the original ...

category: Agile | clicked: 3 | | source: www.kodefuguru.com | show counter code
tags: Refactor, Refactoring, Declarative