Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: Name spaces and Perl::Tk coding style

by chester (Hermit)
on Oct 05, 2005 at 18:55 UTC ( #497702=note: print w/ replies, xml ) Need Help??


in reply to Name spaces and Perl::Tk coding style

So far as making this OO, I wrote something vaguely similar to this recently, in that it had rows of mostly identical widgets to collect user input. I decided that a "row" was a good candidate to be made a class. On a level above that, you could have a "grid" or "row collection" class that handles things like adding and removing rows to a list or grid. Each of those classes would be partially handling some widgets.

In addition to being easier to read, the good thing about this is that in my app you can add and remove rows dynamically. So when you click a button it just calls "add_row()"; click another and it calls "remove_row()". The "grid" object would handle that, and it can make sure you don't have less than $MIN_ROWS rows or more than $MAX_ROWS rows, and keep track of the current number of rows, etc. etc.

Depends what your requirements are though. Only use OO if it makes sense to use it.


Comment on Re: Name spaces and Perl::Tk coding style
Re^2: Name spaces and Perl::Tk coding style
by TGI (Vicar) on Oct 05, 2005 at 20:05 UTC

    What I have is is a complex app that talks to up to 200+ sensors and displays the data, logs it. It also provides a simple serial terminal and an on-line help system. I am adding the ability to trigger notifications based on filtering the sensor readings. I wrote it like all the examples I saw, and despite my best efforts, it's big, ugly, and unweildy.

    For the filter creation I'm going to have to build a rule editor that allows you to specify N clauses ( <FEILD> < IS / IS LESS THAN / IS GREATER THAN > <VALUE> ) and specify whether they are combined as a conjuction (ALL) or disjunction (ANY). I think I will be making a Clause mega-widget. I think I'll use an HList to manage my clause widgets, as it provides the add_row() functionality you describe. HList is pretty cool, if you haven't used it, check it out.


    TGI says moo

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://497702]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2014-07-30 21:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (241 votes), past polls