in reply to Style Question: small and modular, or big enough to do the job in one piece?
It really depends. Asking if 200 lines is too much is kinda like asking is 200 coins too much. It all depends. Do you have 200 pennies, 200 quarters or 200 gold pieces, or a nice mixture? 200 lines means really nothing. When you're looking at those two hundred lines, ask yourself these questions:
How many of them are exact copies?
How many of them are similar copies?
What you want to do here is figure out how much "copy-n-paste" re-use you have - those are prime canidates for refactoring into subroutines.
Once you have the "copy-n-paste" out of the way. Take a look at what's left and ask your self these questions about each subroutine in term (and don't forget the implicit main subroutine).
Is this beastie cohesive - does it do one thing very well or is it
all over the place
Is this beastie coupled - does it depend on global data or does it
poke at other subroutine's data.
Shoot for high cohesiveness and low coupling (the holy grail of programming). The great thing about looking at cohesiveness and coupling at the functional level is that it can really help you refactor code into an OO level - hmmm this set of five methods work on this one data structure while this set of 3 work on another - eureka ... module discovery.
Now once you've done all that, your 200 lines of code may now be 300 lines of code - is that any worse? Well from a run-time perspective - probably. Calling subroutines or loading modules and calling methods cost you. But that cost is hopefully down in the noise and what you really gain is ease of maintainence and ease of extending when new batch jobs come along.
-derby
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Always focus on maintainability...
by dragonchild (Archbishop) on Feb 14, 2002 at 15:41 UTC | |
by Anonymous Monk on Feb 15, 2002 at 06:01 UTC |