When I find something interesting and new, I post it here - that's mostly programming, of course, not everything.

Sunday, December 18, 2005

Object-Oriented Programming

(not worth publishing)

Date: Wed, 22 Mar 2000 13:35:26

Please excuse both my English and my topic.

What is the point of object-oriented programming anyway? Say, you work with C++, but you are not satisfied with this and that; okay, you switch to Java, which gives you more freedom. Then you discover Perl or Python and just find out that all objects are just hashes (using Perl word), that is, associative arrays of named properties that in turn can be objects or scalars. And, in Perl, you can use all these OO paradigms, and at the same time dynamically add (or even remove) properties and methods.

But you are advised to used "accessor methods" to retrieve or set properties, like this:


Now if we have dynamic sets of properties, why bother defining all specific accessor methods? Why not have just this:


anotherObject->getProperty("ThatProperty") );

But for this we already have a much easier way of doing things:

object->{ThisProperty} = anotherObject->{ThatProperty};

Wow, we can handle properties as if they were variables! But they were variables before we introduced "accessor methods", so why all the fuss? Who knows?

No comments:


Subscribe To My Podcast