程序员的修炼之道-从小工到专家

C1 注重实效的哲学 (A Pragmatic Philosophy)

  • 负责(Be Responsible): 提供各种选择,不要找蹩脚的借口。(Provide Options, Don't Make Lame Excuses.)
  • 不要容忍破窗户。(Don't Live with Broken Windows.)
  • 做变化的催化剂。(Be a Catalyst of Change.)
  • 记住/[留心] 大图景。(Remember/[Keep an eye out for] the Big Picture.)
  • 使质量和范围成为需求问题(Make quality and scope to be Requirements Issue.)
  • 定期为你的知识资产投资。(Invest Regularly in Your Knowledge Portfolio.)
    • 每年至少学习一门新语言(Learn At Least One Programming Language in a Year)
    • 每季度阅读一本技术书籍(Read At Least One Book of Technology in a Season)
    • 也要阅读非技术书籍(Also Read Books of Non-Technology)
    • 上课(Take Courses)
    • 参加本地用户组织(Join Local User Groups)
    • 实验不同的环境(Experience Different Environments)
    • 跟上潮流(Keep up with Trends)
    • 上网(Go Online)
  • 批判地分析你读到的和听到的。(Critically Analyze What You Read and Hear.)
  • 你说什么和你怎么说同样重要。(It's Both What You Say and the Way You Say It.)

C2 注重实效的途径 (A Pragmatic Approach)

  • 系统中的每一项知识都必须具有单一、无歧义、权威的表示。
  • 不要重复你自己。(DRY - Don't Repeat Yourself.)
    • 强加的重复(imposed duplication)
    • 无意的重复(inadvertent duplication)
    • 无耐性的重复(impatient duplication)
    • 开发者之间的重复(interdeveloper duplication)
  • 消除无关事物之间的影响。(Eliminate Effects Between Unrelated Things.)
    • 让你的代码保持解耦
    • 避免使用全局数据
    • 避免编写相似的函数
  • 不存在最终决策。(There Are No Final Decisions.)
  • 用曳光弹找到目标。(Use Tracer Bullets to Find the Target.)
    • ✅ 滑板 -> 自行车 -> 摩托车 -> 汽车
    • ❌ 车架 + 引擎 + 轮子 + 其它配件 = 汽车
    • 用户能够及早的看到能工作的东西
    • 开发者构建了一个他们能在其中工作的结构
    • 你有了一个集成平台
    • 你有了可以用于演示的东西
    • 你将更能够感觉到工作进展
  • 估算,以避免发生意外。(Estimate to Avoid Surprises.)
    • 理解提问内容
    • 建立系统的模型
    • 把模型分解为组件
    • 给每个参数指定值
    • 计算答案
    • 追踪你的估算能力
    • 估算项目进度: 检查需求, 分析风险, 设计、实现、集成, 向用户确认
  • 通过代码对进度表进行迭代。(Iterate the Schedule with the Code.)

C3 基本工具 (Basic Tools)

  • 用纯文本保存知识。(Keep Knowledge in Plain Text.)
  • 利用命令 shell 的力量。(Use the Power of Command Shells.)
  • 用好一种编辑器。(Use a Single Editor Well.)
    • 作者估计是个Emacs信徒。。。
  • 总是使用源码控制。(Always Use Source Code Control.)
  • 要修正问题,而不是发出指责。(Fix the Problem, Not the Blame.)
  • 调试的第一准则:别慌!(First Principle of Debuging: Don't Panic!)
  • 不要假定,要证明。(Don't Assume it - Prove It.)
  • 学习一种文本操纵语言。(Learn a Text Manipulation Language.)
  • 代码生成器:编写能写代码的代码。(Code Generator: Write Code That Writes Code.)

C4 注重实效的偏执 (Pragmatic Paranoia)

  • 你不可能写出完美的软件。(You Can't Write Perfect Software.)
  • 按合约设计。(Design by Contracts.[DBC])
    • 前条件 (precondition)
    • 后条件 (postcondition)
    • 类不变项 (class invariant)
    •  1     /**
       2       * @invariant forall Node n in elements() |
       3       *     n.prev() != null
       4       *         implies
       5       *             n.value().compare To(n.prev().value()) > 0
       6       */
       7     public class dbc_list {
       8         /**
       9           * @pre contains(aNode) == false
      10           * @post contains(aNode) == true
      11           */
      12         public void insertNode(final Node aNode) {
      13             // ...
      14         }
      15         // ...
      16     }

       

  • 通过合约进行设计。(Design with Contracts.)
  • 如果它不可能发生,用断言确保它不会发生。(If It Can't Happen, Use Assertion to Ensure That It Won't.)
  • 将异常用于异常的问题。(Use Exception for Exceptional Problems.)
  • 要有始有终。(Finish What You Start.)

C5 弯曲,或折断 (Bend, or Break)

  • 使模块之间的耦合减至最少。(Minimize Coupling Between Modules.)
  • 要配置,不要集成。(Configure, Don't Intergrate.)
  • 将抽象放进代码,细节放进元数据。(Put Abstraction in Code, Details in Metadata.)
  • 分析工作流,以改善并发性。(Analyze Workflow to Improve Concurrency.)
  • 用服务进行设计。(Design Using Services.)
  • 总是为并发进行设计。(Always Design for Concurrency.)
  • 使视图与模型分离。(Separate Views from Models.)
  • 用黑板协调工作流。(Use Blackboards to Coordinate Workflow.)

C6 当你编码时 (While You Are Coding)

  • 不要靠巧合编程。(Don't Program by Coincidence.)
  • 估算你的算法的阶。(Estimate the Order of Your Algorithms.)
  • 测试你的估算。(Test Your Estimate.)
  • 早重构,常重构。(Refactor Early, Refactor Often.)
  • 何时进行重构:
    • 重复
    • 非正交的设计
    • 过时的知识
    • 性能
  • 怎样进行重构:
    • 不要试图在重构的同时增加功能
    • 在开始重构之前,确保你拥有良好的测试
    • 采取短小、深思熟虑的步骤
  • 为测试而设计。(Design to Test.)
  • 测试用装备(Testing Harness):
    • 用以指定设置与清理的标准路径
    • 用以选择个别或所有可用测试的方法
    • 分析输出是否是预期(或意外)结果的手段
    • 标准化的故障报告形式
  • 测试你的软件,否则你的用户就得测试。(Test Your Software, or Your Users Will.)
  • 不要使用你不理解的向导代码。(Don't Use Wizard Code You Don't Understand.)

C7 在项目开始之前 (Before The Project)

  • 不要搜集需求,挖掘它们。(Don't Gather Requirements - Dig for Them.)
  • 与用户一同工作,以像用户一样思考。(Work with a User to Think Like a User.)
  • 抽象比细节活得更长久。(Abstraction Live Longer than Details.)
  • 使用项目词汇表。(User a Project Glossary.)
  • 不要在盒子外面思考 -- 要找到盒子。(Don't think Outside the Box - Find the Box.)
  • 倾听反复出现的疑虑 -- 等你准备好再开始。(Listen to Nagging Doubts - Start When You're Ready.)
  • 对有些事情“做”胜于“描述”,比如“怎样系鞋带”。(Some Things Are Better Done than Described, For Example, Tie the shoelace.)
  • 不要做形式方法的奴隶。(Don't Be a Slave to Formal Methods.)
  • 昂贵的工具不一定能制作出更好的设计。(Expensive Tools Do Not Produce Better Designs.)

C8 注重实效的项目 (Pragmatic Projects)

  • 围绕功能,而不是工作职务进行组织。(Organize Around Functionality, Not Job Functions.)
  • 不要使用手工流程。(Don't Use Manual Procedures.)
  • 早测试,常测试,自动测试。(Test Early, Test Often, Test Automatically.)
  • 要到通过全部测试,编码才算完成。(Coding Ain't Done 'Til All the Tests Run.)
  • 通过“蓄意破坏”测试你的测试。(Use Saboteurs to Test Your Testing.)
  • 测试状态覆盖,而不是代码覆盖。(Test State Coverage, Not Code Coverage.)
  • 一个 bug 只抓一次。(Find Bugs Once.)
  • 把英语当作又一种编程语言。(Treat English as Just Another Programming Language.)
  • 把文档建在里面,不要拴在外面。(Build Documentation In, Don't Bolt It Out.)
  • 温和地超出用户的期望。(Gently Exceed Your Users' Expectations.)
  • 在你的作品上签名。(Sign Your Work.)

转载于:https://www.cnblogs.com/hungry-jimmy/p/10665753.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值