We're sunsetting PodQuest on 2025-07-28. Thank you for your support!
Export Podcast Subscriptions
cover of episode 308 How Many Lines Of Code Should A Function Have? - Simple Programmer Podcast

308 How Many Lines Of Code Should A Function Have? - Simple Programmer Podcast

2016/12/12
logo of podcast Simple Programmer Podcast

Simple Programmer Podcast

Shownotes Transcript

Writing code is definitely an art. It is far from being something automatic. This is so true due to the fact that every software developer writes a different code, based on their personal experience and how they perceive it is the best practice for writing it.

So, one of the most asked questions I receive is how a code should be written and what are the best practices for writing code.

In this video I'll discuss a little bit more about how many lines of code should a function have.

This is such a particular code and a quote from Code Complete Book sums it up really well: "From time to time, a complex algorithm will lead to a longer routine, and in those circumstances, the routine should be allowed to grow organically up to 100-200 lines. (A line is a noncomment, nonblank line of source code.) Decades of evidence say that routines of such length are no more error prone than shorter routines. Let issues such as depth of nesting, number of variables, and other complexity-related considerations dictate the length of the routine rather than imposing a length restriction per se."

Wanna know more about how many lines of could should a function have?

Should You Comment Your Code?: https://www.youtube.com/watch?v=ErW6fEvulAc Clean Code Book: https://simpleprogrammer.com/CleanCodeBook