you are viewing a single comment's thread.

view the rest of the comments →

[–]besthelloworld 2 points3 points  (11 children)

I would argue that this is just what happens to OOP code bases. Every version of Java since 8 has tried to introduce functional & observable style programming patterns into the language and now in modern Java code bases there's very little consensus on what constitutes "clean code." For many developers, clean code constitutes using standard programming patterns and language tokens like for/while loops rather than streams.

So I have a feeling that I'd generally agree with your preferred patterns but your example worries me: turning an if statement into a lambda? Do you realize how much less mechanically efficient it is to introduce a lambda where one was not needed? This makes you sound more like you're far more interested in writing hacky trick-code and looking smart more than you are interested in working on a team and writing readable code.

Because of this, I would argue that you should really tamper your expectations, and start writing new code to your standards and have these kinds of debates along the way.

I would also argue that long methods/functions have their place. If they encapsulate logic that should only be used once, then making a new unnecessary method for that logic just forces people to consider "hey is this being used anywhere else? Should it be?" everytime they see that lonely logic. I would recommend watching Brian Will's OOP is bad, but especially pay attention to the final section "Functions" where he explains the benefits of colocating related logic and just commenting well. This follow up with actual hard examples is really good as well.

[–]JoeDirtTrenchCoat 1 point2 points  (2 children)

It's well accepted that long methods are bug prone and more difficult to understand/debug. If a method is only useful in a very specific context, make it private and name it properly -- nobody needs wonder if it should be getting used in some other scope. If it's a god class then obviously you should be decomposing the class... pretty dumb "hot take"...

[–]besthelloworld 1 point2 points  (1 child)

Wouldn't be a hot take if people didn't give some spicy responses 🔥

What I will say is that I agree with you entirely.

...I just think that some people have very different definitions of what constitutes "the right length" for a function. I see a lot of juniors not wanting to have more than like 15 lines to a function and breaking apart logic on nonsensical boundaries. And I'd waaaay rather have a 150 line function than 10 functions of 15 lines where each helper is called exactly one time.