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.”
Yeah, you heard me.
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 one-hundred-liner functions. I’ve written everything in between, and I have no regrets. So let me teach you some things you should’ve been taught a long time ago.
Lesson 1: Stop using aesthetic arguments
I cringe when developers say “this function just doesn’t look clean” to justify refactoring in lieu of actual reasoning, as if code cleanliness is an aesthetic judgment that only a true connoisseur can determine.
Intuition is valuable, but it’s a hint, not the answer. There’s always a deeper reason. You just may not be articulate enough to express it using reasoned arguments. I can help, but…
Lesson 2: “Lines Of Code” is the last thing you should think about
... continue reading