You're right, there is no formal definition of an object, and there is no single form of object orientation. However, the requirement that an object combine state and behavior is sufficiently general as to be acceptable to nearly everyone, from Smalltalk programmers who would want to talk about behavior as message passing, to C programmers who write functions that take struct pointers as initial arguments.

The reason languages do not allow inheritance of state without behavior is that it runs counter to the goal of encapsulation. Whether you're doing straight function coding or working on a deep OO tree, encapsulation is basically always a good idea. To take the guts out of a subroutine or object and toss away the abstraction layer provided by the interface is to take a step in the opposite direction of ease of development, maintainance, sanity :)

A better way to get at the separation of state from (certain) behavior is to look at something like the classic model-view-controller pattern, where you've got all your state wrapped up in one class, methods for manipulating the state in your controller class, and a presentation layer in the view class. Thus you've got separation and encapsulation, and you haven't introduced this new burden of manually coordinating state and behavior which in the vast majority of cases the programmer is not going to need or want.


In reply to Re: Re: Re: Re: Re: Re: Class::Interface -- isa() Considered Harmful by djantzen
in thread Class::Interface -- isa() Considered Harmful by chromatic

Title:
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, details, 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, summary, 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.