Ducks Can Be Subtle Birds

Posted by Rick DeNatale Thu, 10 Aug 2006 15:09:00 GMT

One theory I’ve seen defines a “duck type” as a set of messages which an object bound to a parameter or value needs to understand. This leads some, who want to make type-checking happen a bit earler, to propose testing the values of such variables with oneor more respond_to? tests before using the object “in anger.”

But ducks can be subtle…

Read more...

Posted in  | Tags , ,  | no comments | no trackbacks

Classes aren't types redux

Posted by Rick DeNatale Tue, 01 Aug 2006 18:55:02 GMT

Programming in a dynamically typed language is sometimes like casting roles in a movie or play. Even if the screenwriter wrote a part with a particular actor in mind, theneed often arises for an understudy or stand-in.

One of the mantras of Duck Typing is that “Classes aren’t types”. Another, more subtle, aspect is that even if it walks and talks, an object needs to be tried out for a role.

In the Pickaxe, Dave Thomas gives, as his first example of duck typing, the usefulnessof of using a String or an Array as a lightweight substitute for a File.

Read more...

Posted in  | no comments | no trackbacks

About me

Posted by Rick DeNatale Sat, 29 Jul 2006 13:34:00 GMT

For those who don’t want to read a lot, or dont care too much, here’s the executive summary:

  • I’m a long time object programmer.
  • I worked for IBM for 31 years.
  • I was one of the early adopters/advocates of Smalltalk in IBM.
  • I’ve done a lot of Smalltalk.
  • I’ve done a lot of standards work.
  • I’ve done a lot of Java.
  • I’m now free of IBM and Java, and I’m learning to love Ruby.

As a result of all of the above I’ve developed lots of strong opinions, weakly held, which I’d like to share.

Now for those with the stamina, some more details on my personal journey…

Read more...

Posted in , ,  | Tags , , ,  | 7 comments | no trackbacks

On Hunting Ducks

Posted by Rick DeNatale Wed, 26 Jul 2006 19:39:00 GMT

Five doctors go duck hunting, they draw lots to determine the order in which they will shoot from the blind.

The Psychiatrist gets the first chance.

A flock of birds fly over. He looks down at his shotgun and says

They look like ducks! They sound like ducks! I wonder how they feel about being ducks?

Meanwhile the birds fly by.

Next up is the internist:

They look like ducks! They sound like ducks! But we can’t rule out the possibility that they might be geese.

Then the general practitioner:

They look like ducks! They sound like ducks! What do you guys think?.

The surgeon takes his place next. He confidently feels the trigger of his shotgun with his highly skilled right forefinger. The next flock flys over.

Bang! Bang!

And the surgeon turns to the pathologist and says:

Check them out and see if they are ducks.

I’ve known this joke for quite a few years, but I’ve never thought about it in relationship to software, until I started playing around with Ruby, and discovered an old friend under a new name, “Duck Typing.”

Read more...

Posted in , ,  | Tags ,  | 6 comments | no trackbacks

Older posts: 1 ... 5 6 7