From: Lionel Bouton Date: 2008-03-11T07:29:55+09:00 Subject: Re: Which is better -- method option or multiple methods? Trans wrote: > In the case of limited options, like the following example, which is > better? > > class String > > def align(direction. spacing) > case direction > [...] > end > > OR > > def align_left(spacing) > ... > end > [...] If the direction is supposed to be static everywhere in the code, I'd use the align_(*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