... but I wonder if anyone has seen a good book that covers OOPerl and Tk, or if they know of a tutorial, or even some well written OOPerl/Tk code that I could peruse.

Well, I don't know of a good book on that specific topic, however, Tk itself is pretty object oriented, so you may want to start there.

Quick Disclaimer: I dont know what you app does, so I am just gonna throw out some things I have done in the past in similar situations.

You can start by taking any custom behaviors you have implemented proceduraly and making them subclassed widgets. Even if you are only adding a single method, or pre-setting some configuration parameters in the widget constructor, it can still be worth it to subclass because of the possiblities for extensibility it gives you later on.

Probably another good place to start is to look at the Tk "MegaWidgets" out on CPAN. You may be able to combine groups of widgets into a single mega-widget if they get reused in other places.

You may also want to think of the different layers of your application as well. n-tier design ideas need not only apply in multi-tier settings. Break out any non-UI parts into their own objects. This can have added benefit later on when you may want to port it out of Tk and into some other platform.

Another thing that I have found very valuable when doing this type of work is to build some kind of regression test. Having some way you can be sure your changes did not break anything will save you a lot of time. Then you can refactor and make these changes incrementally and test after each one.

As for the global variable thing, you will likely be able to get rid of most of them in the refactoring process, for the rest of them, all I can say is Singletons.

Hopefully some of this will be useful to you :)

-stvn

In reply to Re: OO Perl and Tk by stvn
in thread OO Perl and Tk 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.