Refactor code with return statements <p>The "if" blocks with checkcustomers are exactly used in other methods in this class, so there is a lot of code dublication for same checks. But I cant also directly extract this checksomethings to one single method because they have return values.</p> <p>Some good ideas to refactor this code? I just modified this code to simplify here, so dont get caught on minor issues in this code(if any), Basically question is how to a extract a piece of code to a method(because it is dublicated on other methods) when there are many returns in that current method.</p> <pre><code>public Details getCustomerDetails(){ if(checkifcustomerhasnoboobs){ ..worry about it.. return new Details("no"); } if(checkifcustomerplaytenniswell){ ..do find a tennis teacher return new Details("no cantplay"); } //...ok now if customer passed the test, now do the some real stuff // // CustomerDetails details= getCustomerDetailsFromSomewhere(); return details; } </code></pre>