Hi, there is a rule that suggests to use and/or boolean operations instead of
multiple returns.
For example it suggests agains using:
isTranslucentButNotTransparent
backgroundColor ifNil: [ ^ true ].
(backgroundColor isColor and: [ backgroundColor
isTranslucentButNotTransparent ]) ifTrue: [ ^ true ].
(borderColor isColor and: [ borderColor
isTranslucentButNotTransparent ]) ifTrue: [ ^ true ].
^ false
Instead you should use:
isTranslucentButNotTransparent
^ backgroundColor isNil or: [
(backgroundColor isColor and: [ backgroundColor
isTranslucentButNotTransparent ]) or: [
borderColor isColor and: [ borderColor
isTranslucentButNotTransparent ] ] ]
And at least a few developers think that the suggested implementation is more
complicated to comprehend.
What is the reasoning behind the rule? Does the suggested version run faster
(i.e. is optimized ing some way?).
Cheers.
Uko