Down, up, super and base

Down, up, super and base

  • Comments 2

Sometimes the programming language is determining the perspective. Last week I read the definition of downcasting on Wikipedia:

In object-oriented programming, downcasting or type refinement is the act of casting a pointer or a reference to a base class to one to a derived class.

I think this sentence is not very lucky, because if you read it for the first time, it is not clear why downcasting is not called upcasting (and vice versa). Casting from a base class to one to a derived class gives me the impression to go up and not down.

Generally it seems to me that understanding the terms upcasting and downcasting is much easier in Java or X++ then in C# because of the keyword super. Super is related to the Greek word hyper and means above. This is the complete opposite to the keyword base in C# which Latin origin means low. The following graphic illustrates this difference:

Reading directions

Now back to the downcasting explanation, you see, that the term downcasting isn't an ergonomic term for a C# developer:

downcasting

I'd like to know what C# developers are thinking about this.

Leave a Comment
  • Please add 4 and 8 and type the answer here:
  • Post
  • I'm a C# developer, and I don't agree with your assertion. Even though C# uses the keyword "base," I still draw inheritance diagrams with the base class above the derived class, and so the term "downcasting" seems natural for me.

    But I think the direction - up or down - isn't really criticial. What is important is that most people follow the same convention so that we have a common language.

    It's like in electrical circuits - we think about current flowing from positive to negative, even though it was discovered long ago that electrons actually travel in the opposite direction. But everyone still follows the old convention anyway. It doesn't matter which is right or wrong, so long as we all agree to do our analysis the same way.

  • 3.1 Changing types (converting and casting) C# is an strongly-typed programming language (even if there

Page 1 of 1 (2 items)