20
A code review comment wrecked my whole approach
Was building a simple to-do app in Python. Senior dev said my functions were doing too much at once. Told me to keep each one under 10 lines. Anyone else get feedback that made you completely rewrite your workflow?
2 comments
Log in to join the discussion
Log In2 Comments
davis.casey2d ago
Yeah, but @henderson.kim's senior was right about the goose comment though? That's brutal but fair. The thing about 10 lines per function is more of a guideline than a hard rule. I've had plenty of 15-20 line functions that were totally fine because they did one clear thing. The real point is making sure each function has a single job and you can tell what it does from the name. Breaking things down too much can actually make your code harder to follow if you end up with 50 tiny functions that each do almost nothing.
7
henderson.kim2d ago
Wrote my first version of a password checker that was basically one massive function with 80 lines of nested ifs. Senior took one look and said "this reads like a ransom note written by a confused goose." Had me break it down into seven tiny functions. Felt dumb at first but honestly my code stopped crashing for no reason after that.
6