Programming style: using Classes or inline



I suppose this is more of a Perl question, but since I'm working with
Gtk, maybe it will pass.. :)

I'm quite new to Perl programming, and for starters, I have built a
gtk-perl interface to my PostGresql business records database.  Some of
my windows are built with glade using libglade and some are hand-built.
Actually, I have three *.glade files - one for the main window, one for
a database selection dialog and the other is a form for data entry,
edit, or delete.  I have others which I built by hand.  After reading a
recent message regarding using Glade, I may regret this.

I first tried to keep my perl source separated into 3 files, all inline
code without making any packages, including the other two into the main
program by "use" statements, but when I added "use strict", I found that
I had to tie the variables to a package, so I just made them all "my
variables" - but, at least as far as I could see, they were not
recognized across files, so I just merged them all into a single file.

For a little perspective, my code now occupies some 1500+ lines.

Now, after reading Grant McLean's glade-article.pdf tutorial, I have a
bit more insight into classes, I'm wondering if there might be a great
advantage in using Classes, or if inline is just as good.  What I have
is working quite flawlessly, but if Classes are better, now might be a
good time to redesign the thing.

Also, if I were to adapt some of the routines to Classes, what's
normally best - separate files or a single file?  In this case, this
program is strictly for my own use.  I don't plan on distributing it.
I'd be happy to, but I seriously doubt if anyone but myself would find
it useful - well, it's built for my particular table layout.  Also,
these routines for the windows are probably not reusable.  I mention all
this in regard to my question regarding separate files for the classes,
etc.

Basically, after all the above, what I'm asking is for some pointers as
to where Classes are beneficial and where not, and the same for multiple
files.

Thanks to anyone who might bear with me on this possibly OT query.



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]