in reply to Refactoring a large script
refactoring/improving/tightening/increasing the speed and efficiency of the program
I think you first need to ask yourself which goal you are pursuing. "Refactoring" is usually associated with removing duplicate code and generally improving the maintainability of your code. Efficiency is a different thing entirely (and sometimes opposite, as refactoring things into subroutines increases overhead).
For efficiency, it's critical to figure out real bottlenecks and here profiling tools will help. See Devel::DProf for examples. Once you've identified particular bottlenecks, work on those or post examples to Perl Monks if you're stuck. Don't overlook all the good Tutorials.
There are also some great reference books on these topics. The book that's almost written for your case is "Perl Medic: Transforming Legacy Code" by Peter J. Scott.
For refactoring, for the most part, just look for things that you do over and over again (cut-and-paste stuff) and try to isolate that into separate subroutines. If you're up to it, you could consider pushing some of it into separate modules. (See How a script becomes a module).
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Refactoring a large script
by mdunnbass (Monk) on Jan 18, 2007 at 17:12 UTC | |
by xdg (Monsignor) on Jan 18, 2007 at 18:28 UTC | |
by mdunnbass (Monk) on Jan 19, 2007 at 18:27 UTC | |
by BrowserUk (Patriarch) on Jan 20, 2007 at 04:30 UTC | |
by mdunnbass (Monk) on Jan 21, 2007 at 04:12 UTC | |
by mdunnbass (Monk) on Jan 23, 2007 at 15:50 UTC | |
|