Summer Blog

代码检视

代码质量

  1. 命名
    1. 不杂不漏
    2. 避免误导
    3. 保持一致
      1. 建立词汇表
      2. 使用业务词汇
  2. 拆解复杂代码-圈复杂度和认知复杂度
    1. 复杂度识别
      1. 圈复杂度
        1. 线性 = 1
        2. 循环 or 判断 or 嵌套 = 分支数+1
      2. 认知复杂度:人理解的维度判断复杂度,一个分支复杂度+1
    2. 拆解负载代码
      1. 拆解点:找循环、找判断、找注释
      2. 方法:利用重构工具、提炼函数、提炼参数、重命名
      3. 测试:单元测试
  3. 提升质量的阶段
    1. 初级:命名合理、避免复杂代码、去除重复、基本重构、基本自动化
    2. 中级:合理分配对象职责、合理分层架构、运用设计模式、去除隐含重复、高级重构技术、恰当自动化测试
    3. 高级:合理领域模型、模型一致性、合理分配子系统和模块职责、演进式架构、合理数据库模式

阅读Guava代码

7 Rules to Maximize Misery and Stress

Video

formula: stress = unsatisfied desire _ T = want/have _ T

There are two way to increase stress:

7 Rules:

  1. Desire to be there, not here
    1. There is where but not here.
    2. There is that place where you have more.
    3. It’s that the magic destination that you’re always running towards.
    4. Once you desire to be there, it’s very important that you never arrive.
  2. Never learn from your mistakes, or better yet, repeat them
  3. Be ungrateful
    1. Remove the word enough from your vocabulary and replace it with more.
    2. Refuse to enjoy simple pleasures like a sunny day, a nice meal, or a good joke, because that might convince you it’s okay to be right here, right now.
    3. Trave from destination to destination, never stopping to smell the roses along the way.
  4. Be arrogant
  5. Ruminate endlessly
  6. Don’t live sustainably
  7. Keep people who follow the other principles around you