Lionel Bouton
3/10/2008 11:56:00 PM
Paul Mckibbin wrote:
> Lionel Bouton wrote:
>> If the direction is supposed to be static everywhere in the code, I'd
>> use the align_<direction>(*args) methods.
>>
>> But if the direction is dynamic (based on a property, a preference, any
>> algorithm, ...) then I'd use the align(direction, *args) method.
>> Otherwise you will get
>>
>> case direction
>> when :left
>> align_left(...)
>> when :right
>> align_right(...)
>> when :center
>> align_center(...)
>> end
>>
>> constructs everywhere...
>>
>> But I'd probably use the align_* methods to implement align(direction,
>> ...) for readability and flexibility anyway. In this case align_* would
>> be private if you don't need them to simplify the API or public if you
>> actually need them.
>>
>> Lionel
>
> Surely then there would then be a decision making process that would set
> the variable <direction>
That's what I meant by "dynamic"...
>, and how is that simpler than calling the
> function?
It's not. It's why it was used as an argument for the case where you'd
prefer to make this function public (assuming we speak of
align(direction, *args)): the "dynamic" one.
Was my post so confusing?
>
> In any case, you can replace your "case direction" constructs with
>
> send("align_#{direction}",spacing)
Of course you can. But I won't: I don't find this coding-style very
maintainable or easy to read. It's a matter of taste, I only presented
mine...
Lionel