Perfil de QianIndoMITable HerMITFotosBlogListasMás ![]() | Ayuda |
|
20 marzo Walk the walk, talk the talkDuck typing can generate controversy. Every now and then a thread flares on the mail- ing lists, or someone blogs for or against the concept. Many of the contributors to these discussions have some fairly extreme positions. Ultimately, though, duck typing isn’t a set of rules; it’s just a style of programming. Design your programs to balance paranoia and flexibility. If you feel the need to con- strain the types of objects that the users of a method pass in, ask yourself why. Try to determine what could go wrong if you were expecting a String and instead get an Array. Sometimes, the difference is crucially important. Often, though, it isn’t. Try erring on the more permissive side for a while, and see if bad things happen. If not, perhaps duck typing isn’t just for the birds. --From "Programming Ruby 2nd Edition" |
|
|