Perfil de QianIndoMITable HerMITFotosBlogListasMás Herramientas Ayuda

Blog


29 marzo

觉得这句话讲得真好

      “也许是我曾行走得太快,上天逼我停下来看看风景。狭隘的争论与表面的荣辱,渐渐变作细碎的杂音。如果这样可以消除浮躁,等待也未必就是浪费。”
     
       继续等待,心平气和~
20 marzo

Walk the walk, talk the talk

Duck 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"