This question could be applicable to any programming language, really, but it sort of works out well because I'm using perl. :)

In OOP, how should interpackage coordination work? I have several objects that read off of data objects in another package. There is a primary object that controls the other objects. Here is my plan right now:

Primary (one object to rule them all; global config, etc.)
- Parse (parses input)
- DataManager (stores data objects)
- DataObjects (stores data objects)
- UI (input/output)
- Search

UI -> Parse -> DataManager -> DataObjects
UI -> Search -> DataManager -> DataObjects -> DataManager -> 
   Search -> UI

Thats all fine and good and it makes sense laid out, My problem is connecting it all. If I send a big config hash to Primary, I have to pass a reference to the Primary object to _every_ new sub-package object that I make. There has got to be a better way!

Having to refer to a Primary's object ref, then to the ref to another package, then to whatever else I need in the package, etc. seems really clumsy. $name = $ui->{main}->{data}->{data_obj_ref}->name :shudder: I don't know what my exact question is, other than "what am I doing wrong here?" This can't be right, and I feel I'm sort of getting the short end of the deal; I'm (attempting) to go with OO but I'm going through more work accessing objects between packages than I am making it easier to maintain.

I would really appreciate any help or suggestions. Thanks.

-billyak

In reply to Cross-Package/Object Communication by billyak

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.