《精益软件开发艺术》读书笔记(2) « 贾磊的博客

持续集成

精简代码

对需求优先级进行排序

  • 根据客户价值进行基本优先级排序(对于web应用,客户显然就是网站的最终用户),决定哪些是最重要的是是客户,而不是开发人员。
  • 重估优先级,在每个迭xx始重新进行一次优先级排序,确保每次都吸纳了客户对需求的变更。
  • 应该对需求进行独立的优先级排序,而不是简单地设置为“高”、“中”、“低”,用数字来{wy}标示需求的优先级。

短迭代、只为当前迭代而开发

  • 如果不是需要,就别去做
  • 好吧,设计什么时候开始做?如果不做设计就开始开发,那么是否会导致大量的返工,如果做了过多的设计,是否会使得代码过于庞大。
  • 作为web应用,坚持优先开发核心功能,always beta, 持续重整是不错的思路。

代码重用

  • python 的 batteries included,支持代码重用,它的思路不光是,嘿,你可以使用别人的,更重要的是,你想创建一个给别人用也非常的简单。

编码规范和{zj0}实践

python的编码规范参见。(另外中文版参见)

我摘录关心的几条在这里

  • Imports should be grouped in the following order:
  1. standord library imports
  2. related third-party imports
  3. local application/library specific imports

  • Put any relevant __all__ specification after the imports.

  • Comments should be complete sentences.  If a comment is a phrase or
        sentence, its first word should be capitalized, unless it is an identifier
        that begins with a lower case letter

  • An inline comment is a comment on the same line as a statement.  Inline
        comments should be separated by at least two spaces from the statement.
        They should start with a # and a single space.

  •  __version__ = "$Revision: 68852 $"

  • In addition, the following special forms using leading or trailing underscores are recognized (these can generally be combined with any case convention)
  1. _single_leading_underscore: weak “internal use” indicator.
  2. single_trailing_underscore_:? 为了避免同python的关键词重复,在{zh1}一个词后加下划线
  3. __double_leading_underscore:? 在类中标注是私有变量,其实是被重命名了,例如Foo类下面定义私有变量__A, 那么如果你真的想得到这个变量,必须使用 Foo()._Foo__A来访问。
  4. __double_leading_and_trailing_underscore__: 特殊的对象或者属性,存在于用户控制的命名空间。
  • 模块名应该没有下划线
  • 类名使用首字母大写单词串的格式
  • Because exceptions should be classes, the class naming convention
          applies here.  However, you should use the suffix "Error" on your
          exception names (if the exception actually is an error).

  •  Modules that are designed for use via "from M import *" should use the
          __all__ mechanism to prevent exporting globals

  • Function names should be lowercase, with words separated by underscores as necessary to improve readability.
  •  Constants are usually declared on a module level and written in all
           capital letters with underscores separating words.  Examples include
           MAX_OVERFLOW and TOTAL.
  • 为了继承而设计,通常,当你不确定将一个属性公有还是私有的时候,私有是个主意,这样你就不用为调用这个类的其他组件就这个属性做任何保证,这通常意味着更少的依赖。
  • Avoid using properties for computationally expensive
            operations; the attribute notation makes the caller believe
            that access is (relatively) cheap. (不要把一个需要消耗大量计算时间才能得到的结果作为类的属性,因为调用者通常会认为得到一个类的属性是很廉价的)
  •  Modules or packages should define their own domain-specific base
          exception class, which should be subclassed from the built-in Exception
          class.  Always include a class docstring.  E.g.:
    
            class MessageError(Exception):
                """Base class for errors in the email package."""
  • When raising an exception, use "raise ValueError('message')" instead of
          the older form "raise ValueError, 'message'".
  • for all try/except clauses, limit the 'try' clause
          to the absolute minimum amount of code necessary.  Again, this
          avoids masking bugs.
  • Object type comparisons should always use isinstance() instead
          of comparing types directly.
  • When checking if an object is a string, keep in mind that it might be a
          unicode string too!

使用设计模式
重构代码和设计
  • 通过一种简单的,甚至是比较勉强的解决方案来实现需求,然后通过重构是得解决方案尽可能的高效。

短迭代周期

使用短迭代周期进行开发

  • 根据排定优先级的需求进行工作
  • 设定迭代周期长度,并且严格遵循
  • 一个不容侵犯的结束日期起到两个作用:确保客户能够获得新功能进行定期评测,让开发团队聚焦于一处

Leave a Reply

郑重声明:资讯 【《精益软件开发艺术》读书笔记(2) « 贾磊的博客】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——