in reply to Passing variables is as easy as passing gas

Code that is 1000+ lines and is not OO probably should be OO. Do what dragonchild says, or read this book: Object Oriented Perl and learn how to decompose your logic into a set of maintable, understandable, and hopefully readable classes. Hell, do both!

Global variables are not a BAD thing - but they can be easily abused about 1000 lines into your code. By encapsulating these variables into proper classes, you will hopefully achieve better code re-use. I say hopefully because first attempts at OO are usually not pretty. :)

jeffa

  • Comment on (jeffa) Re: Passing variables is as easy as passing gas

Replies are listed 'Best First'.
Re: (jeffa) Re: Passing variables is as easy as passing gas
by mattg (Novice) on Nov 03, 2001 at 01:20 UTC
    Okay, I'll show my utter ignorance of OO and ask if OO in Perl is anything more (in a general sense, of course) than modularized subroutines? Aside from the global variables, I've broken the script up into numerous subroutines all of which operate (as much as is possible) independent of each other.

    Also, of the 4000 lines, only about 750 are actually in the main loop of the Tk interface, the rest are taken up by the subroutines (21 in total). It's for this reason that the global variables worry me, because after a while it does become difficult to know where they have been littered throughout the subroutines and ensure that I haven't accidentally put them in a position of being modified (but I'm checking my code with a fine-toothed comb now, as the saying goes).

    I'm going to see if I can get my hands on a copy of the OO Perl book, and will see what I can do about putting the globals into a module. Thanks for the responses!

    matt