All Topics
All Topics
Technology
Technology
Design
Design
Programming
Programming
Science
Science
News
News
Gaming
Gaming
Entertainment
Entertainment
Business
Business
Finance
Finance
Sports
Sports
Health
Health
Food
Food
Travel
Travel
Art
Art
Music
Music
Books
Books
Education
Education
Politics
Politics
Personal
Personal
No algorithm. No AI slop. No ads. Just RSS. Pro-human. Indie writers. Real journalism. Open web. Chronological. Hand toasted.

Why Lines of Code Is a Poor Metric for Function Design

By

Axol

7mo ago· 14 min readenOpinion

Summary

This article argues against using lines of code (LoC) as the primary metric for determining when to break functions into smaller pieces. The author criticizes developers who automatically split functions based solely on length rather than considering factors like repetition, reusability, and logical cohesion. The piece advocates for a more thoughtful approach to function design that focuses on actual code quality rather than arbitrary line count thresholds.

Key quotes

· 4 pulled
What's the quickest giveaway that someone's an amateur developer? When they tell you to break out a function into smaller functions, and the first reason they cite is 'it's over X lines of code.'
This article is targeted at people who are so easily intimidated by long functions that they fail to see deeper issues with them.
It's about people who take a linear function with no repetition or need for reusability, break it out into smaller functions, and think they accomplished something.
I've written one-liner functions (besides getters and setters). I've written functions that are hundreds of lines long. The length of the function is not the problem.
Snippet from the RSS feed
What’s the quickest giveaway that someone’s an amateur developer? When they tell you to break out a function into smaller functions, and the first reason they cite is “it’s …

You might also wanna read