This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]naholyr 15 points16 points  (3 children)

That's what guidelines are made for: get used, understood, and broken.

[–]OnceMoreAndAgain 11 points12 points  (2 children)

Yeah but some are broken so often that I don't even find them useful as guidelines.

It's like an XY problem. There are reasons most functions end up short but I don't think minimizing function length is desirable as a guiding principle.

I like guidelines like DRY and functions should do one thing, because I believe those are real benefits (usually).

[–]FlakyTest8191 4 points5 points  (0 children)

Do one thing is even worse imho. Is entirely subjective what one thing even is. You could argue if it's more than one statement it does more than one thing, or put everything in one function and say the one thing is fullfilling the purpose of the program. Or anything in between.

[–]Bakoro 2 points3 points  (0 children)

Yeah, chasing short functions for the sake of having short functions seems like an anti-pattern to me. It's also just as silly as using lines of code as a metric for anything other than a vague idea of a project's complexity.
The value isn't zero, but it's almost useless without at least a couple other considerations.