摘要: 今天看到一篇关于怎样避免使用switch而用enum的文章,看了以后感觉作者想法挺好的,这里共享出来。原文地址:Avoid switch! Useenum!Recently I was about to refactor some code Crap4j pointed me to. When I realized most of that code was some kind of switch-case or if-else-cascade, I remembered Daniel´s post and decided to obey those four rules.This 阅读全文
posted @ 2010-12-22 08:17 程序员天下 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 原文地址:An advent of unconditional qualitycodeThis blog entry invites you to an experiment in code. It’s an experiment that runs four weeks and can be performed secretly even at your workplace. It might improve the way you think about conditional statements in an object oriented programming language. Y 阅读全文
posted @ 2010-12-22 08:05 程序员天下 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 原文地址:The Simplest Anti-IF CodeThe basic problem is that IFs create dependencies, coupling between modules (methods, objects, components, etc.) and increases possible paths inside our code (which reduces legibility).An IF seems like a quick and easy way to make changes, but for the reasons listed abo 阅读全文
posted @ 2010-12-22 08:01 程序员天下 阅读(162) 评论(0) 推荐(0) 编辑