Clean Code - How to Write Amazing Functions

Topics covered
Popular Clips
Episode Highlights
Function Size
The team discusses the ideal size of functions, emphasizing that smaller functions are easier to understand and maintain. Michael Outlaw highlights that if a function takes more than three minutes to comprehend, it's too complex 1. Alan Underwood adds that functions should be concise, ideally no more than 20 lines long 1. Joe Zack shares his experience of refining a complex function over two hours to improve readability and efficiency 2.
All functions start as trees until you whittle them down to toothpicks.
--- Michael Outlaw
  Â
Naming Conventions
Naming conventions play a crucial role in code readability and maintainability. Michael Outlaw advises against using vague names like 'manager' or 'helper,' advocating for more descriptive names 3. Joe Zack emphasizes that function names should clearly indicate their purpose, and long names are acceptable if they enhance clarity 4. He also notes the importance of using standard naming conventions like 'get' and 'set' appropriately 4.
Functions should be verb names and your properties should be noun names.
--- Michael Outlaw
  Â
Function Arguments
Managing function arguments effectively is essential for clean code. Joe Zack points out that functions should ideally have no more than two arguments to simplify testing and reduce complexity 5. Michael Outlaw agrees, noting that too many arguments can lead to clutter and make the code harder to maintain 6. They also discuss the use of configuration objects to handle multiple arguments more efficiently 6.
The more arguments you add, the more difficult it is to isolate things to that one particular method.
--- Alan Underwood
Related Episodes
Clean Code - Formatting Matters
Answers 383 questions

Clean Code - How to Write Classes the Right Way
Answers 383 questionsHow to be a Programmer
Answers 383 questions

Clean Code - Comments Are Lies
Answers 383 questions

Clean Code - How to Build Maintainable Systems
Answers 383 questionsDesign Patterns Part 3
Answers 383 questionsHow to be an Intermediate Programmer
Answers 383 questionsClean Code - Writing Meaningful Names
Answers 383 questionsDesign Patterns Part 1
Answers 383 questionsHow to be an Advanced Programmer
Answers 383 questions

Clean Architecture - Programming Paradigms
Answers 383 questions

Write Great APIs
Answers 383 questions

Clean Architecture - Are Microservices Truly Decoupled?
Answers 383 questions
Clean Architecture - Fight for Architecture
Answers 383 questionsJavascript Promises and Beyond
Answers 383 questions
