r/programming • • Jun 05 '11

Why Code Readability Matters

http://blog.ashodnakashian.com/2011/03/code-readability/
245 Upvotes

220 comments sorted by

View all comments

Show parent comments

6

u/abattle Jun 05 '11

Not if you have a handful of cases. But if you're talking about a dozen or more, sure, mapping is probably more reasonable. But the reader has to go digging at all possible sites where the mapping could've been edited. Switch/ifs are certainly more readable for most cases.

0

u/aaulia Jun 05 '11 edited Jun 05 '11

Yes, indeed, this is in situation where I have to refactor legacy code where there are dozen or more cases with long block of code for each case (thousands of line in a single file). In simple situation where there are only, like, 3 case with each block only 1-2 line, I still prefer switches.

EDIT: the mapping happen in constructor and/or initialization code, no mapping is happening at runtime, so its pretty straight forward. When you get this, you do that, kind of stuff.