程序设计实践阅读摘要[一]

本文摘自《程序设计实践》,强调了编程中的关键要素:使用描述性的全局名称和简洁的局部名称,保持一致性,谨慎处理副作用,避免使用函数宏,用常量代替魔法数字,并提供了关于注释的实用建议。此外,推荐了《编程风格的元素》和《代码大全》作为补充阅读。
摘要由CSDN通过智能技术生成

1.1 Names 

    1.Use descriptive names for global, short names for local

        Clarity is often achieved through brievity

    2 Be Constant 

    3 Use active names for functions

        checkoctal Vs isoctal


1.2 Expressions and Statement

    1.Break up complex expressions

        *x += (0xp = (2*k < (n-m) ? c[k+1]: d[k--]));

         Vs

        if (2 * k < n-m)

            *xp = c[k+1];

        else

            *xp = d[k--];

        *x += *xp;

    2.Be carefull with side effects

        scanf("%d %d" &yr, &profit[yr]);


1.3 Consistency and idioms

 

1.4 Functions Macros

    1 Avoid function macros

        parameter appears more than once in the definition might be evaluated more than once

    2 Parenthesize the macro body

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值