Writing Functions (Uncle Bob's principles)

shoiabakbar

Shoaib Akbar

Posted on July 7, 2020

Writing Functions (Uncle Bob's principles)

Some principles to write functions from Clean Code book

  1. The first rule of functions is that they should be small.
  2. The second rule of functions is that they should be smaller
    than that (upto 20 lines of code)

  3. FUNCTIONS SHOULD DO ONE THING

  4. Function Arguments

  • Better if no argument

  • Functions should have maximum of 2 arguments

  • But arguments should not be exceeded by 3
    (They take a lot of conceptual power)

  • It should has same level of abstraction
    (1 level of abstraction)

  • Passing a boolean into a function is a truly terrible
    practice. (Flag as argument)

Keep Learning!!

💖 💪 🙅 🚩
shoiabakbar
Shoaib Akbar

Posted on July 7, 2020

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related