4 ms·
I used to follow a bunch of best practices like this, that I now often find to be of too little benefit. If the function is small, multiple return statements wo
by genwin 13y ago
I used to follow a bunch of best practices like this, that I now often find to be of too little benefit. If the function is small, multiple return statements won't significantly affect readability and it's simpler to code.
- igouy 13y ago>> If the function is small << And if the function is not small?
- mseepgood 13y agoThen extract functions until it's small, a.k.a. refactoring.
- marshray 13y ago...and if you end up needing to pass 20 variables via reference for state?
- masklinn 13y agohttp://www.refactoring.com/catalog/introduceParameterObject.html http://www.refactoring.com/catalog/introduceParameterObject....
- marshray 13y agoYou have a group of parameters that naturally go together. ...when you have a bunch of methods that call each other, all of which have a clump of parameters that need this refactoring. In this case you don't want to apply Introduce Parameter Object because it would lead to lots of new objects There are times when this transformation yields simpler code, there are times when it makes things more complex, and there are a lot of cases in between where it's a judgment call.
- genwin 13y agoThen I might set a variable and return that. The goal is to make the function readily understood.