Every so often, I get the chance to use functions that accepts a nondescript boolean as parameter... or *gasp* a sequence of nondescript booleans.
api.connect( true )
It's a chore for the maintainer (usually my future self) to have to look up what "true" meant. IDEs might be helpful at this point, bringing up code hints and what not.. unless of cos the function declaration itself isn't exactly perfect...
def connect(bool)
...
end
I've finally come round to do myself a favor (ok, I AM going to be the maintainer) by using self-explanatory truthy / falsey values instead
api.connect( :auto_retry )# trueapi.connect(!:auto_retry)# false
Reads better. No?
Much better!
-d
Posted by: Daniel | August 26, 2007 at 09:55 AM
Personally, I prefer this more verbose invocation:
api.connect(:auto_retry => true)
Posted by: Doug | August 26, 2007 at 04:46 PM
@doug: if u wrote the method, sure! i was talking more abt 3rd party's
Image.capture(false, false, false, false, true)
photo.contrast(true)
Posted by: choonkeat | August 26, 2007 at 05:04 PM