Esteemed monks,

I have a rather large Perl/Tk application, the codebase for which stretches back as far as 1997. It refuses to stop growing and for some totally inapparent reason, people keep wanting to use it and ask for all sorts of additions. I am now faced with making some changes that I think require a major overhaul - and I don't know how to do this, hence I supplicate myself before you seeking enlightenment.

What I have

The application is a reasonably sophisticated front end to MySQL, origianly it used just DBI but about two years ago I started adding Class::DBI into the mix and now it uses a mixture of both appproaches in different places.

Originally the whole thing was written following the example of Mastering Perl/Tk and was a single great big script. That was fine until it got to about 3000 lines. So I started to abstract logical sections into modules, which usually relate to something like a Tk::NoteBook panel, or some other chunk of GUI with logic. The config handle, the dbh handle and the MainWindow are all created near the top of the current 3700 line main code. The individual Tk::NoteBook panels are then 'created' and when the module is loaded a hash of configuration variables is passed in, like this:

my $excluder = MyApp::Exclude->new( -mw => $mw, -monitor => $monitor, -cfg => $cfg, -dbh => $dbh, ); $excluder->draw();
You can probably figure out what is happening, the -mw config variable is the MainWindow handle and is used to add the GUI elements, the -cfg and -dbh get the config and database handles.

Where I need to go

This monster now has a 3700 line main 'module' with about 40 self-written modules, all of which currently totals over 30,000 lines of custom code. And now I face a dilemna.

I want to add a Tk::StatusBar to the bottom of the main window, that's the easy part. But how do I expose the various methods for maniuplating the status bar to the many and varied places in my code which may want to toggle a little annunciator block, or manipulate a progress bar, or change a label text?

How do I structure something like this? Especially when some objects - which need ultimately to manipulate the MainWindw status bar, might be created by another object thus placing the child at a 'distance' from the Main?

I have tried understanding TheDamian through Object Oriented Perl and Perl Best Practices but my poor feeble brain seems to be not getting something.

jdtoronto


In reply to How to structure LARGE Perl/Tk application? by jdtoronto

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.