Why Lines of Code Is a Poor Metric for Function Design
By
Axol
Hand-rolled, kettle-boiled, baked to perfection. Worth every minute at the bakery.
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 pulledWhat'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.
You might also wanna read
Programming Philosophy: Writing Self-Debugging Code with Clear Design Principles
The article discusses programming philosophy and code quality principles, focusing on writing code that balances functionality, performance,
Detail Code Analysis Tool Finds Critical Bugs in Codebases
Detail is a code analysis tool that scans codebases to find serious bugs, security vulnerabilities, data loss issues, and billing mistakes.
detail.dev·5mo agoThe Problem with Edge-Case First Library Development in Software Ecosystems
The article critiques the trend in software development where libraries are built to handle edge cases first, leading to bloated dependency
Code as Debt: Why Less Code is Better for Software Companies
The article presents an analogy comparing two companies to argue that less code is better, framing code as 'debt' that creates maintenance b
Evaluating the Impact of LLM-Generated Code in Software Development
The article discusses the author's perspective on the increasing use of LLM-generated code in software development. The author expresses fru
Why Average LLM Use Is Likely Destroying Value in Software Development
The author argues that, contrary to prevailing hype, the average use of Large Language Models (LLMs) is likely destroying value rather than
