Clean coding-practices - Wakaleo Consulting

  • Choose names well

    • 愛他就不要拋棄他Choose 1 and stick to it
    • Use Meaningful names
    • 若即若離Don't talk in code, but don't state the obvious
    • Don't make me think!
    • Explicit method name
    • Clear parameter name
    • What are we counting?
    • Encapsulate boolean expressions: Method call rather than boolean expression
  • Let your code tell story

    • Methods should be small
    • Methods should only do one thing, stop mixing what & how
    • Choose what to do
    • The how is the responsibility of another class
    • Encapsulate boolean expressions
    • Avoid unclear/ambiguous class name
    • Avoid deep nesting
  • Code should communicate fluently

    • Use fluent APIs: Method chaining/cascading (return this;),
    • P32 :builder + abstract class + override
    • Replace constructors with creation methods
    • Encapsulate classes with factory
    • Functional Programming


comments powered by Disqus
Copyright © 2013 Andro Chen
Powered by Logdown and Greyshade
Favicon from The Noun Project