Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

The definition of OO is unclear

I've recently been reading Booch's "Object-Oriented Analysis and Design", which contained a passage that made the reason for all this confusion over what OO is suddenly clear for me: the term "object" arose independently from several branches of CS at about the same time, each expressing a similar idea, yet just different enough to be confusing.

In such a case, it seems foolish to define OO along a single means of implementation. In Java, classes are always defined with a class Foo, plus some optional inheirtance declaration, followed by a block containg the class definition. Objects are always defined with a Foo f = new Foo(); statement, plus some optional parameters to the constructor. If you're not doing that, you're not doing OO, as far as the Java people will tell you.

What they have really done is implemented a single kind of OO and ignored a large and useful number other kinds of OO. Perl's bless'd objects are roughly analogous to Java's object system, and it's the one that gets the most attention, but it's hardly the only one. Just off the top of my head, it also has:

  • Inside-out objects
  • Classless objects
  • Closures

And probably a lot more that I don't know about, or even have yet to be discovered. The important point is that these have massively different implementations, but can all be unified under the banner of OO.

Another thing I've noticed is some OO programmers describing OO concepts in terms of how it's implemented in their favorite language. It is ironic that OO, which is about abstracting the interface from the implementation, is often described in terms of implementation. For instance, I once saw a C++ programmer explain polymorphisim (here on Kuro5hin.org) like this:

Polymorphism - The class contains a pointer to the appropriate function to call that can handle the class specific data. This is done so to provide a consistant interface.

Yes, that's how polymorphism is implemented in C++. But it doesn't have to work like that. Perl's bless'd objects, for instance, does polymorphisim by walking the inheirtance tree (not that this is a great way to do it--it's slow).

----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer

: () { :|:& };:

Note: All code is untested, unless otherwise stated


In reply to Re: The world is not object oriented by hardburn
in thread The world is not object oriented by tilly

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (1)
As of 2024-04-18 23:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found