Giter Site home page Giter Site logo

cleancode's Introduction

My learning note about Clean Code

  1. Your name must answer this question:
    1.a. Why it exists?
    1.b. What it does?
    1.c. How it is used?
  2. Choose descriptive and unambiguous names.
  3. Make meaningful distinction.
  4. Use pronounceable names.
  5. Use searchable names.
  6. Don't use prefix.
  7. Use domain name.
  1. Do one thing.
  2. Use descriptive names.
  3. Zero or one argument.
  4. No output argument.
  5. No flag argument.
  6. Have no side effect.
  7. DRY.
  8. Fail fast.
  1. Don't write comment to explain your code.
  2. Try to express our code.
    2.a Give a meaningful name.
    2.b Put in the right context.
  3. Comments are always evolved to follow the code.
  1. It's all about communication.
  2. Vertical formatting is like reading a newspaper.
  3. 80 chars width.
  4. If we work in a team, use team rules (create it if you don't have).
  1. Everything is an object is a myth.
  2. Avoid hybrids structures (half object and half data).
  3. Keep class field private and final.
  4. Obey the Law of Demeter (LoD).
  5. Don't use setter or getter.
  1. Avoid using exception for flow control.
  2. Use checked exception.
  3. Don't return NULL.
  4. Don't pass NULL.
  5. Use fail fast.
  6. Don't catch until you have to.
  7. Provide context with exception.
  1. Try to encapsulate any boundary interface inside a class.
    1.a. Avoid returning it or accepting it as an argument.
  2. Learn your boundaries by writing a tests.
  3. If your boundaries not yet available, create it.
    3.a. You can use adapter pattern as a bridge when they are available to use.

Reference:
Martin, Robert C. 2009. Clean code: a handbook of agile software craftsmanship. Upper Saddle River, NJ: Prentice Hall.
Bugayenko, Yegor. 2017. Elegant Object Volume 1. CreateSpace Independent Publishing Platform; 1.0 edition (February 17, 2016)
Bugayenko, Yegor. 2017. Elegant Object Volume 2. CreateSpace Independent Publishing Platform; 1.4 edition (April 18, 2017)

cleancode's People

Contributors

bluething avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.