Friends,

Recently I bought the 1994 edition of the "Gang of Four" Design Patterns book. I've been reading it and it has taught me a lot of things already that I did not know before.

For a project I continually work on to exercise my Perl skills, I am thinking of implementing the following (my methodology might still be way off) :

I'd like to have objects that are in a certain state. When interacted with their state changes and they will call some kind of notification method on themselves. By calling this, let's say, $self->notify(), other objects will recieve this and act accordingly. This should form some kind of response-to-notification event model.

I am not sure how I would implement such in Perl, therefore I would like to lay this before the hive mind that is PerlMonks, and see what your thoughts are on this.

Thanks for reading,

-- jkva

Update :
So far I am thinking that all objects classes are subclasses of a class which has a notify() method, which calls some kind of hub class, which knows about all objects and notifies them, this way there would be some kind "distributed awareness". Just doodling with my mind here, it might be very bad :)


In reply to Implementing an event-driven object model in Perl by jkva

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.