In talking with people, I'm looking at extending my Hash::Merge class to include OOP abilities. Certainly not a huge problem, at least from the standpoint of creating a Factory-like object similar to CGI.pm which basically gives a way to handle operations with some degree of specification, as opposed to being a data-storage object.

However, in this case, it also seems worthwhile to develop a tied hash variable such that one can continually merge hashes into the tied hash, eg: my $tied_hash = ...; $tied_hash->merge( %new_hash ). (and for those reading and wondering about a mix of hash and object, see Object and tied hash all at once?). Now, I would think the best way to do this functionality is to create the subclass inside this class *preferably* in the same file only because the main Hash::Merge class would have a Factory method to generate an instance of this tied hash:

my $tied_hash = Hash::Merge::create_tied_hash( %defaults );
as opposed to:
my $tied_hash = \tie( %defaults, "Hash::Merge::Tied" );
It's not that I'm tried to hide this tied class, but I feel that the factory method is more intuitive towards my module, since Hash::Merge functions will have to be used if you are only on planning on using the tied class. Placing this subclass in the same file of course will prevent someone from 'use'ing it, from my understanding, since use is looking at the file structure and not inside the files.

However, from an openness standpoint, it's probably better to have this tied as a separate file. Nothing will break because of that, but again, to me, it doesn't seem 'right', as a user can directly create this tied variable without using the Factory method of the Hash::Merge class. But again, there is nothing *special* about the Factory method that cannot be moved into the new method of the tied class.

So is it generally bad form to try to insulate the users from subclasses that they shouldn't know too much of the specifics of, or is it better to have as open an interface as possible for this?

-----------------------------------------------------
Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
"I can see my house from here!"
It's not what you know, but knowing how to find it if you don't know that's important


In reply to Use of embedded classes by Masem

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.