Closed golszewski86 closed 5 months ago
@golszewski86/z this project will fix the problem faster if you donate a few dollars to it; just click here and pay via Stripe, it's very fast, convenient and appreciated; thanks a lot!
@golszewski86 this is a question to @yegor256
More thoughts about the rule https://softwareengineering.stackexchange.com/questions/118703/where-did-the-notion-of-one-return-only-come-from
@golszewski86 definitely, there are arguments in favor of multiple returns, but Qulice is a very opinionated and extreme toolkit. We only believe in what we like, and we strongly disagree with everything else :)
There is a rule defined in qulice-checkstyle/src/main/resources/com/qulice/checkstyle/checks.xml file:
This rule however has no real justification. Yes I read the blog post https://www.yegor256.com/2015/08/18/multiple-return-statements-in-oop.html but it's not conclusive. It present the perfect OO approach but then states it's impossible in java because "Java doesn’t have that. Java (and many other pseudo OOP languages) gives us operators" followed by some consideration how the perfect OO language would look like. And the last statement is " let’s stick with just one return".
Why? What's the difference between returning value directly and assigning it to a variable and returning this variable? Those are two very similar ways of writing the same, except the direct return requires less code is more readable.