Downcasting, what’s up with that?

Just a short post today, or a question rather, on what must be the easiest subject I’ve written about yet. Though, I’ve caught myself making errors against it often. Nowadays I’m extra cautious when writing about inheritance.

What do you think about first when you hear “up”?

graph upviagra-pills

What do you think about first when you hear “down”?

down graph.png

 

Now, how do we programmers interpret upcasting and downcasting?

updown

You upcast to an object which can do less, and you downcast to an object which can do more.

What’s up with that?

UPDATE: I have since started a discussion on this on Programmers Stack Exchange.

Advertisements
  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: