How Many Lines Of Code Should A Function Have?

Опубликовано: 13 Октябрь 2024
на канале: Simple Programmer
303
9

"The secret to retiring early and true financial freedom:"
https://simpleprogrammer.com/wellsecret

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 the 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."

Want to know more about how many lines of could should, a function have? Watch this video and find out!

📖 THE COMPLETE SOFTWARE DEVELOPER'S CAREER GUIDE 📖
Get #1 bestselling book, The Complete Software Developer's Career Guide https://simpleprogrammer.com/careerguide

🛑 SUBSCRIBE! 🛑
   / @simpleprogrammer  

💲 CREATE A BLOG TO BOOST YOUR CAREER - FREE COURSE 💲
Take this free course and learn how to make more money, improve your career and even make some side income.
https://simpleprogrammer.com/lp/creat...

📚 ARE YOU MAKING ONE OF THESE LEARNING MISTAKES? 📚
Most software developers are learning the wrong way!
https://simpleprogrammer.com/lp/5-lea...

💲 7 REASONS YOU ARE UNDERPAID AS A SW DEVELOPER 💲
Find out what they are...
https://simpleprogrammer.com/lp/7-rea...

🤴 EXCLUSIVE SIMPLE PROGRAMMER MEMBER COMMUNITY 🤴
Join a supportive, motivated community of developers that will keep you energized and making progress toward your goals
https://simpleprogrammer.com/store/pr...

📚 BOOKS AND RESOURCES I RECOMMEND 📚
https://simpleprogrammer.com/resources/

💲 HOW TO MARKET YOURSELF AS A SOFTWARE DEVELOPER 💲
Learn to build a personal brand, get a higher salary, become a respected name in the industry.
https://simpleprogrammer.com/store/pr...

🏫 TEN STEPS TO LEARN ANYTHING QUICKLY 🏫
Learn how to learn.
https://simpleprogrammer.com/store/pr...

👕 TRUST THE PROCESS SIMPLE PROGRAMMER SHIRT 👕
https://simpleprogrammer.com/store/pr...

🔎 LINKS YOU MIGHT LIKE 🔎
Simple Programmer Website: http://simpleprogrammer.com/
Soft Skills Book: http://simpleprogrammer.com/softskills

🎬 SOCIAL MEDIA 🎬
Facebook:   / simpleprogrammer  
Twitter:   / simpleprogrammr  
IG:   / simpleprogrammer