Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris

Comment on

( #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 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

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (3)
    As of 2018-03-18 10:35 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (229 votes). Check out past polls.