November 7, 2008

Object Oriented Ponderings

Posted in Uncategorized at 7:53 pm by carolynresearch

After nobody showed up for my last two office hours, I had one taker today. I ended up in a bit of a “philosophical” discussion with him. I said something about an instantiation operation returning an object (a concretization of a class), and he disagreed, said it returned a handle. This student seemed to think that you couldn’t consider the address of a complex structure, and this was all important. I had a bit of a discussion with him about abstractions and the idea of types – it just didn’t make sense for him to say that a variable had an object type.

He also was trying to structure his code well, and his idea of doing so was to create a lot of classes, and put all of the “action” into their constructors, because he didn’t want to just have his code be all one method. I tried to convince him that a constructor should construct an instance of the class, not just do things. It got me thinking – maybe it’s just because of when I learned to program, but I’ve always thought of classes as being essentially abstract data types. I’ve been told not to – but I still can’t break the habit. Yes, you have inheritance in a class system, and polymorphism, but these always seemed to me to be extra tools in the same basic attempt at abstraction and encapsulation.

The worst object oriented code I’ve seen has tried to to separate every bit of logic into its own class, with constructors which do lots more than construct. Maybe it has something to do with people using one of the languages where everything has to be an object, and a program is a constructor.

Or maybe I just think too much. I’m not with Dijkstra about Object Oriented Programming, but I do question the “everything is an object” idea.


Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: