Hi Monks!

I'm writing a small program to monitor several Sybase servers.
These servers are of different types like Replication Server, Adaptive Server and so on.
The types have serveral things in common, like 'show overall status' and the like, but do also several things different.

This looks pretty much like an object hierarchy with a Server object as parent class and an ASE/RS/anything object inheriting from Server.

So far no problem. But upon creation time the server object does not know which type it is.
Only if it can connect to the real server, it can determine it's type.

So at the moment I don't have a hierarchy but one object (server) and some files with the funktions used by the various types.
I create a Server object. Let it determine it's own type by connecting to the real server. Import the necessary functions and use it's own dispatch table.

It works, but it's not as object oriented as I would like and it's hard to follow, what's really happening.

So, finally, here my question: Is it possible to create an object of a parent class, let it determine it's type and become an object that is further down the hierarchy?


In reply to change object class during runtime 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.