Hi Yuriy,
to me the first form is a list of simple rules.
The second one is a complex expression

You made an effort to keep the list format for the second expression, while
violating traditional block formatting which would be



     ^ backgroundColor isNil
or: [
                (backgroundColor isColor and: [ backgroundColor
isTranslucentButNotTransparent ]) or: [
                borderColor isColor and: [ borderColor
isTranslucentButNotTransparent ] ] ]

I don't think that runtime optimization count at all in such choice.

2017-04-07 10:33 GMT+02:00 Yuriy Tymchuk <[email protected]>:

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

Reply via email to