Clean Code 阅读笔记

  • 初期未记录,待二次阅读。。。
Concurrency
  1. Keep your concurrrency-related code separate from other code.
  2. Take data encapsulation to heart; severely limit the access of any data that may be shared.
  3. Attempt to partition data into independent subsets than can be operated on by independent threads, possibly in different processors.
  4. Review the classes available to you. In the case of Java, become familiar with java.util.concurrent, java.util.concurrent.atomic, java.util.concurrent.locks
  5. Learn these basic algorithms and understand their solutions: Producer-Consumer, Reader-Writer, Dining Philosophers.
  6. Avoiding using more than one method on a shared object.
    • Client-Based Locking
    • Server-Based Locking
    • Adapted Server
  7. Keep your synchronized sections as small as possible.
  8. Think about shut-down early and get it working early. It’s going to take longer than you expect. Review existing algorithms because this is probably harder than you think.
  9. Write tests that have the potential to expose problems and then run them frequently, with different programatic configurations and system configurations and load. If tests ever fail, track down the failure. Don’t ignore a failure just because the tests pass on a subsequent run.
Refactor
  1. no pass a flag as an argument to a function, especially when that flag simply selects the format of the output
Code Smells

Comment

  1. Inappropriate Information
  2. Obsolete Comment
  3. Redundant Comment
  4. Poorly Written Comment
  5. Commented-Out Code

Environment

  1. Build Requires More Than One Step
  2. Test Require More Than One Step

Functions

  1. Too Many Arguments
  2. Output Arguments
  3. Flag Arguments
  4. Dead Function

General

  1. Multiple Languages in One Source File
  2. Obvious Behavior Is Unimplemented
  3. Incorrect Behavior at the Boundaries
  4. Overridden Safeties
  5. Duplication
  6. Code at Wrong Level of Abstraction
  7. Base Classes Depending on Their Derivatives
  8. Too Much Information
  9. Dead Code
  10. Vertical Separation
  11. Inconsistency
  12. Clutter
  13. Artificial Coupling
  14. Feature Envy
  15. Selector Arguments
  16. Obscured Intent
  17. Misplaced Responsibility
  18. Inappropriate Static
  19. Use Explanatory Variables
  20. Function Names Should Say What They Do
  21. Understand the Algorithm
  22. Make Logical Dependencies Physical
  23. Prefer Polymorphism to If/Else or Switch/Case
  24. Follow Standard Conventions
  25. Replace Magic Numbers with Named Constants
  26. Be Precise
  27. Structure over Convention
  28. Encapsulate Conditionals
  29. Avoid Negative Conditionals
  30. Functions Should Do One Thing
  31. Hidden Temporal Couplings
  32. Don’t Be Arbitrary
  33. Encapsulate Boundary Conditions
  34. Functions Should Descend Only One Level of Abstraction
  35. Keep Configurable Data at High Levels
  36. Avoid Transitive Navigation

Java

  1. Avoid Long Import Lists by Using Wildcards
  2. Don’t Inherit Constants
  3. Constants verus Enums

Names

  1. Choose Descriptive Names
  2. Choose Names at the Appropriate Level of Abstraction
  3. Use Standard Nomenclature Where Possible
  4. Unambiguous Names
  5. Use Long Names for Long Scopes
  6. Avoid Encodings
  7. Names Should Describe Side-Effects

Tests

  1. Insufficient Tests
  2. Use a Coverage Tool!
  3. Don’t Skip Trivial Tests
  4. An Ignored Test Is a Question about an Ambiguity
  5. Test Boundary Conditions
  6. Exhaustively Test Near Bugs
  7. Patterns of Failure Are Revealing
  8. Test Coverage Patterns Can Be Revealing
  9. Tests Should Be Fast
Concurrency of Appendix
  1. Focuse all concurrency code into a small number of classes
  2. Understand the memory model enough to know what is and is not safe
  • 25
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值