Clean-code
昨日不可追
技术人生、终身学习、投资创业|明日不可待,昨日不可追!
展开
-
Clean Code 读书笔记六
类单一权责(SRP)public class SuperDashboard extends JFrame implements MetaDataUser { public Component getLastFocusedComponent() public void setLastFocused(Component lastFocused) public int getM原创 2015-06-22 10:51:02 · 1105 阅读 · 0 评论 -
Clean Code 读书笔记五
Use Exception Rather than Return Code(使用异常而不是错误处理) public class DeviceController {... public void sendShutDown() { DeviceHandle handle = getHandle(DEV1); // Check the state of the d原创 2015-06-19 22:43:02 · 1031 阅读 · 0 评论 -
Clean Code 读书笔记四
能用代表表述的就不要用注释 减少注释,把精力放在代码上,让代码说话,而不是注释不要写add by 的注释,用svn 、git管理组件就可以了**代码中不要保留注释的代码 例如://Check to see if the employee is eligible for full benefitsif ((employee.flags & HOURLY_FLAG) &&(employe原创 2015-06-14 16:46:11 · 822 阅读 · 0 评论 -
Clean Code 读书笔记七
clean code 之 系统构建与使用分离 Software systems should separate the startup process, when the application objects are constructed and the dependencies are “wired” together, from the runtime logic that tak原创 2015-06-22 12:17:12 · 925 阅读 · 0 评论 -
Clean Code 读书笔记八
简单设计四规则:• Runs all the tests • Contains no duplication • Expresses the intent of the programmer • Minimizes the number of classes and methods (作者认为的金钥匙)运行所有测试低耦合 高内聚 造成的结果就是会有更多的类与方法。我们就更易编写独立的单元测试原创 2015-06-22 17:39:33 · 1016 阅读 · 0 评论 -
Clean Code 读书笔记二
细节汇总:拒绝在容器类型的命名中使用 该容器类型 List flaggedCells = new ArrayList(); As we’ll see later on, even if the container is a List , it’s probably better not to encode the container type into the name. -相同的意思,原创 2015-06-06 13:22:53 · 979 阅读 · 0 评论 -
Clean Code 读书笔记三——方法(函数)
clean code 之方法(函数)- 短小 ,再短小,更短小 20行最佳只做一件事 准确说来每个方法应该是只做抽象概念上的的一件事 只做一件事的方法是无法把逻辑分段的自顶向下的代码 To say this differently, we want to be able to read the program as though it were a set of TO paragra原创 2015-06-07 03:01:53 · 1791 阅读 · 0 评论 -
Clean Code 读书笔记一——什么是 clean code?
什么是 clean code ?大神对优雅代码的定义: I like my code to be elegant and efficient. Thelogic should be straightforward to make it hardfor bugs to hide, the dependencies minimal toease maintenance, error han原创 2015-06-05 23:21:00 · 2618 阅读 · 0 评论 -
Clean Code 读书笔记九
要点汇总:一般性问题方法名称应该准确表达其具体行为 比如:Date newDate = date.add(5)//加5天?5个月?最好使用addDaysTo 或increaseByDays 明确方法的行为。使用多态 代替 switch或if else 比如:class RequestHandler { public void handleRequest(int action) {原创 2015-07-06 22:47:05 · 955 阅读 · 0 评论