qulice icon indicating copy to clipboard operation
qulice copied to clipboard

There is no reason for single return

Open golszewski86 opened this issue 6 years ago • 4 comments

There is a rule defined in qulice-checkstyle/src/main/resources/com/qulice/checkstyle/checks.xml file:

<module name="ReturnCount">
   <property name="max" value="1"/>
</module>

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.

golszewski86 avatar Nov 21 '18 07:11 golszewski86

@krzyk/z please, pay attention to this issue

0crat avatar Nov 21 '18 07:11 0crat

@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!

0crat avatar Nov 21 '18 07:11 0crat

@golszewski86 this is a question to @yegor256

krzyk avatar Jan 30 '19 12:01 krzyk

More thoughts about the rule https://softwareengineering.stackexchange.com/questions/118703/where-did-the-notion-of-one-return-only-come-from

longtimeago avatar Aug 19 '19 15:08 longtimeago