函数设计要避免太多的的参数
Functions should have a small number of arguments. No argument is best, followed by one, two, and three. More than three is very questionable and should be avoided with prejudice.
Robert C. Martin
函数应该使用少量的参数,最好的情况是不使用参数,一至三个参数也是可以的。拥有3个以上参数的函数往往不容易让人理解函数的意图,应该尽量避免这种情况。当函数确实是需要有多个参数时,可以将多个参数组成一个Class或Structure。
分类: 软件设计
