Don’t Repeat Yourself (DRY)
DRY 是一个最简单的法则,也是最容易被理解的。但它也可能是最难被应用的(因为要做到这样,我们需要在泛型设计上做相当的努力,这并不是一件容易的事)。它意味着,当我们在两个或多个地方的时候发现一些相似的代码的时候,我们需要把他们的共性抽象出来形一个唯一的新方法,并且改变现有的地方的代码让他们以一些合适的参数调用这个新的方法。
参考:htt...
分类:
其他好文 时间:
2016-06-24 15:58:42
阅读次数:
152
Any day will do? Any message for me? Are you by yourself? All right with you? Are you kidding me? Are you free tomorrow? As soon as possible. Back in ...
分类:
其他好文 时间:
2016-06-19 23:02:07
阅读次数:
184
Binary Tree Right Side View
Total Accepted: 44458 Total
Submissions: 125991 Difficulty: Medium
Given a binary tree, imagine yourself standing on the right side of it, return ...
分类:
其他好文 时间:
2016-06-12 02:00:55
阅读次数:
171
Q:
Implement atoi to convert a string to an integer.
Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below and ask yourself what are the possible ...
分类:
编程语言 时间:
2016-06-07 14:57:10
阅读次数:
320
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. For exa ...
分类:
其他好文 时间:
2016-05-24 16:44:01
阅读次数:
113
在用C++进行面向对象编程的时候,有时需要在一个类里包含两个代码相似的函数,而它们之间的唯一区别是,一个为const类型,一个是non-const类型。 此时如果将相同的代码写在两个函数中,则严重违反了DRT(Don't repeat yourself)原则。正确的做法是:让non-const函数引 ...
分类:
其他好文 时间:
2016-05-01 23:01:50
阅读次数:
212
1 List[] extends 2 dictionary {} has_key() keys() values() 3 json: dumps dump 4 docstring:' ' " " ''' ''' 5 object: __ne__ _gte__ super(Book,self).__i ...
分类:
其他好文 时间:
2016-04-30 16:55:28
阅读次数:
137
Total Accepted: 40438 Total
Submissions: 117654 Difficulty: Medium
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered...
分类:
其他好文 时间:
2016-04-29 18:57:13
阅读次数:
184
精神食量,不限程序员 非常重要的个人品质 1.TemperanceEat not to dullness,drink not to elevator. 2.Silence:Speak not but what may benefit others or yourself.Avoid trifling ...
分类:
其他好文 时间:
2016-04-27 12:50:56
阅读次数:
140
Total Accepted: 40438 Total
Submissions: 117654 Difficulty: Medium
Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered...
分类:
其他好文 时间:
2016-04-26 21:10:16
阅读次数:
192