Forgive me as I trot out an old, tired, and yet still very relevant cliche: KISS.

Yes, pTk (and Perl in general) provide lots of clever ways to do things, esp. for propagating events. And they're very convenient if an app is 100 lines or less in size.

But when dealing with large scale apps, with lots of GUI components and HMI interactions, I've learned the hard way that keeping to simple disciplines is a far better solution than trying to implement every clever bit of minimalist sigilism.

I've developed a large scale IDE for database apps in Perl and pTk. At first, it was very organic: model and view were all tangled up together. That worked OK when there were 4-5 distinct HMI functions. But the logic got very convoluted after that. Ultimately, I took 3 or more big steps back and rewrote the app to completely separate the GUI from the app logic. As in isolating the View code completely, and explicitly routing all the GUI events to the model through an imperative controller interface.

No, its not sexy. And its a bit more code, It even starts looking like Java at times. It makes me cringe a bit every time I think about the overhead of passing events and responses back and forth through a Controller object.

But every time I put it away for 3 months, and then go back to do some maintenance, I can quickly dive back in. Perhaps as importantly, I'm in the process of converting everything to a browser based solution, and its much easier to focus on just the view components, and XHR all the interactions back to the model.

My advice is to avoid the pitfall of trying to be too clever. Perl and pTk provide many opportunities to use short cuts. They're great for golfing quick solutions to simple problems to impress friends and coworkers. But in the arena of large scale GUI apps, its probably best to let the right and left cranial lobes each focus on the things they do well, and implement a simple bridge between them. Within their hemispheres, feel free to minimize as much as you like; but trying to optimize by declaratively leaking GUI event dispatch into the model will eventually become a liability.


In reply to Re: Perl Tk - propagating events by renodino
in thread Perl Tk - propagating events by TGI

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.