On 19 February 2010 06:28, acreadinglist [email protected] wrote:
eventually) would have to remember to normalize a number before
passing it in.
I like to follow the pattern of fixing one, and only one, problem at a
time; first, get the finder working, then move onto the next task.
In this case the next task is to dry up all that normalization…
so you’ve got something like this duplicated in lots of controllers:
phone_number = phone_number_normalize_method(params[:phone_number])
@people = Person.find_by_phone_number(phone_number)
(hopefully the “phone_number_normalize_method” is somewhere shared,
not copied into every controller…
so to save having to remember to normalize, extract that pattern as a
class method on Person; so the process becomes: