Hacker News new | ask | show | jobs
by mr_crankypants 2528 days ago
Yeah. It's not necessarily that I don't think that it's useful to place limits on length. It's more that it's hard for me to imagine a situation where a godzilla method like that sails past code review, but then gets broken up, anyway, because the static analysis tool said, "Oh, hey, getting a little big there." A static analysis tool is best when it's used for catching things that are hard to see. I'd argue that employing it as a substitute for caring about your code is more of a misuse. And that using it as a substitute for a culture of careful, diligent code review is just a special case of that.
1 comments

Among every team I've worked on there have been the devs that have a real eye for detail and truly care about code quality and put real thought into their work. And there are the ones who are just trying to get paid and don't really think too much about it. I trust the former, I don't trust the latter.

The point is the static analysis tool fails the build, so it becomes physically impossible for the godzilla method to exist. I trust the machine to produce a predictable result. People are a huge source of entropy and having a little bit of automation to help contain some of that entropy I think is a very wise use of technology in CONJUCTION with promoting a culture of caring about quality and diligent review.

It's hard to imagine how anyone ever lets godzilla methods and god objects and all other kinds of code smells become a thing... and yet... they're a real phenomenon that seem to make their way into large code bases at some point or other.

And I guess my concern is that doing something like this is probably solving the wrong problem.

I've worked with people who write messy, tangled code in giant methods, and my experience has been that forcing them to write smaller functions is futile. Satisfying the static analyzer is just too easy: Move all your variables into mutable fields that all the methods fiddle with, break the contents of the method out into smaller methods with cryptic and misleading names, create a master method that calls them all in a row. Voila, with barely any effort you've satisfied the static analyzer and made the code even less maintainable.

Ah OK. Point taken. Yeah... that's a thorny issue. I still prefer both measures. I don't see whats wrong with relying on all tools in your toolbox than preferring one over the other.

Human factors always mess up software... _sigh_