High-Quality Routines(2)

原创 2004年09月23日 14:47:00
How to Use Routine Parameters
1. Put parameters in input-modify-output order
Instead of ordering parameters randomly or alphabetically, list the parameters that are input-only first, input-and-output second, and output-only third.
2. If several routines use similar parameters, put the similar parameters in a consistent order.
3. Use all the parameters.
If you pass a parameter to a routine, use it. If you aren't using it, remove the parameter from the routine interface.
4. Don't use routine parameters as working variables.
5. Document interface assumptions about parameters.
If you assume the data being passed to your routine has certain characteristics, document the assumptions as you make them.
The kind of interface assumptions about parameters we should document:
    Whether parameters are input-only, modified, or output-only.
    Units of numeric parameters(inches, feet,meters and so on)
    Meaning of status codes and error values if enumerated type aren't used.
    Rangers of expected values.
    Specific values that shoudl never appear.
6. Limit the number of a routine's parameters to about seven.
7. Consider an input, modify, and output naming convention for parameters.
8. Pass the variables or objects that the routine needs to maintain it's interface abstraction.
If a routine need 3 paramethers that include in an object, pass the 3 parameters or the entire object?
To solve the problem, think that what abstraction is presented by the routine's interface?
    If the abstraction is that the routine expects you to have 3 specific data elements, and it is only a coincidence that those 3 elements happend to be provided by the same object, then you should pass the 3 specific data individually.
    If the abstraction is that you will always have that particular object in hand and the routine will do something or other with that object, then you truly do break the abstraction when you expose the 3 specific data elements.
9. Don't assume anything about the parameter-passing mechanism.
10. Make sure actual parameters match formal parameters.

High-Quality Routines(1)

What is a "routine"?A routine is an individual method or procedure invocable for a  single purpose.W...
  • wangjiong
  • wangjiong
  • 2004年09月22日 18:44
  • 556

the thinker of code complete -- High-Quality Routines

1.名字尽量好,变量尽量少. 2.尽量实现子函数的内聚性. 3. 一定要判断函数的参数; 作为输入的参数,不要作为返回值,多申请一个变量; 多申请一个变量接受函数的返回值,再作判断. 重要一点不要...
  • u011370933
  • u011370933
  • 2013年12月29日 11:27
  • 468

[Code Complete] CH7 High-Quality Routines高质量子程序

1.       构造子程序的目的:是否需要的标准 Ø  降低复杂度:我们需要不停的抽象,忘记实现细节,使用抽象后的方法来编程。 Ø  引入中间、易懂的抽象:把很短的程序写成子程序的原因。 Ø ...
  • mumubaba
  • mumubaba
  • 2013年06月07日 02:09
  • 465

解决PHP报错 SSL routines:ssl3_get_server_certificate:certificate verify failed

Win7 PHP获取HTTPS网站报错PHP Warning 'yii\base\ErrorException' with message 'get_meta_tags(): SSL operati ...
  • default7
  • default7
  • 2017年08月09日 18:25
  • 380

代码大全学习-10-高质量的函数(High-Quality Routines)

讲完了高质量的类,第七章就接着讲了高质量的函数。     要创建函数的原因像创建类的原因一样有很多:降低复杂性;引入便于理解的抽象;避免重复的代码;支持子类;隐藏顺序执行的过程;隐藏指针操作;增加可...
  • tyst08
  • tyst08
  • 2012年07月21日 12:41
  • 448


OpenSSL命令行常用功能(1) 作者:rainbow 文章出处:中国信息安全组织 发布时间:2...
  • jiangxinyu
  • jiangxinyu
  • 2007年09月04日 14:49
  • 2033

error:140A90F1:SSL routines:SSL_CTX_new:unable to load ssl2 md5 routines

Find the following information: http://comments.gmane.org/gmane.comp.lib.boost.asio.user/2099...
  • dssxk
  • dssxk
  • 2017年01月04日 16:25
  • 587

全民付手机接口开发生产环境error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

近日,公司业务需要,做手机web支付,用的是全民付的手机支付,对方给的php开发文档很简陋,逻辑还是很简单的,经过写代码,测试环境下一切正常, 切换到线上环境时,返回空白, 打印curl的错误信息...
  • bt060218
  • bt060218
  • 2014年06月18日 16:11
  • 9193

easy_install——error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed -- S

今天在安装python模块的时候, 出现一个问题:
  • yunjingguang
  • yunjingguang
  • 2014年08月15日 10:14
  • 3464

javax.crypto.BadPaddingException: error:0407106B:rsa routines:RSA_padding_check_PKCS1_type_2:block t

RSA超过长度时报这个错,解决方法是  加密使用117 解密使用128 public static byte[] encryptByPublicKey(byte[] data, Publi...
  • u014737138
  • u014737138
  • 2017年06月02日 10:32
  • 854
您举报文章:High-Quality Routines(2)