Programming style

2.2 Motivation

Programming style can be defined as: ...the way that a programmer brings clarity, maintainability, testability, reliability, and efficiency to the code of a module. This definition sets the objectives for good programming style but it does not help to determine whether a piece of software is of good or bad style. One can easily conclude that coding itself is only one factor in reaching these goals: a badly designed module can hardly be clear, maintainable, testable, or reliable, even if it is coded in the best possible style. On the other hand, even the most excellent design cannot make the software clear and maintainable if its implementation, the code, is of bad quality. In a software platform it is necessary that the programmers have a similar style. Otherwise software maintenance is too expensive and difficult and reuse becomes almost impossible. A uniform way of coding contributes strongly to the programming productivity of the organization.

abstract from 《S60 code convention》

2.2 动机

程序设计风格可以如此定义:它是一种方式,程序员可以给模块的代码带来清晰性,易维护性,可测试性,可靠性和代码效率。这个定义为好的程序风格而设置了一个目标,但它无助于确定一个软件是好的风格(软件风格的概念有点费解)还是坏的风格。(好的程序风格和软件风格显然不是一个概念)人们容易得出结论:编码风格本身只是达到这些目标其中之一的因素,一个糟糕设计的模块很难会是清晰的,易维护的,易测试的,可靠的,即使它是用最好的编码风格,仍是差质量的。(笔者个人以为好的设计可以解除耦合,比糟糕的实现还是要好。在软件工程实践中,好的编码风格容易形成,好的架构设计难得。笔者推测Nokia可能在这上面吃过亏的。)反过来说,就算是最优秀的设计也不能使软件清晰易维护,如果它的实现,就是代码,是一个差质量的。在一个软件平台里,这是必须的,程序员使用相似的编码风格。否则软件维护将是昂贵的,复杂难解的,并几乎变得不可重用。一致的编码将大大有助于组织的程序生产力。(一致的程序风格,减少理解的代价,使代码容易阅读。但是在具体操作中,发现两个问题,第一:需要留出充分时间,需要给开发人员,这是在变动的组织需要注意的,需要对新人加以培训;第二,进度与规范并重,不能操之过急,使开发人员养成习惯,如果的确很急,功能先行,代码规范随后补上。没有人否定两者都重要,但是在面对冲突时,却往往没能采取正确的处理,可叹。

摘至《S60编码规范》

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值