Hi Monks!

I asked this question a few days ago and got VERY good answers from various monks (Masem knobunc tye tilly bikeNomad). Many thanks!

I'm pondering on the problem since. Not the programmatical solutions but the concepts behind.
Let me draw two pictures, that will show the two concepts:

1. Using a connection object to talk to the server:

+----------+ +--------------+ +-------+ | | | | | | | server | <----> | connection | <----> | gui | | | | | | | +----------+ +--------------+ +-------+ \ \ +-------------+ | | | something | | else | | | +-------------+
Using this model, I can exchange the server object at will, because everything is talking to the connection.

2. Using a server object, that will change it's class:

+----------+ +-------+ | | | | | server | <----> | gui | | | | | +----------+ +-------+ \ \ +-------------+ | | | something | | else | | | +-------------+
Using this model, I cannot exchange the server object at will, because everything is talking to it directly and I had to inform every other object about the change. Hence the reblessing and I don't have to change anything.

From the object oriented view, model one is cleaner and in other languages the only possibility.
From the real world view, model two is closer to what one thinks and only possible in perl (I think, but I don't know every language in the world).

Since I tend to think that OO should represent the real world and how we think about it, I find model two more plausible. I wouldn't ask a connection about the state of a server, I would ask the server!

What do you think?


In reply to Reblessing by busunsl

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.