Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

Re: Finding duplicated code in Perl

by dragonchild (Archbishop)
on Nov 26, 2003 at 13:08 UTC ( #310226=note: print w/ replies, xml ) Need Help??

in reply to Finding duplicated code in Perl

As someone who's taken over a similar project in the past, I'm going to give you a piece of advice you're not going to want to hear. Do it by hand. Do not use a tool to do your work.

  • Tools don't understand architecture
  • Tools cannot give you proper naming
  • Tools cannot tell you how to optimize code
  • Tools cannot give you new features by noticing commonalities between dissimilar areas
  • Tools cannot comment confusing code
  • Tools cannot create the third and fourth levels of modules/objects - the basic infrastructure that the code users run depends on, but that users never see

As if that isn't enough, you're probably going to also need a whole bunch of documentation. I'll bet you don't have most of the following:

  • Project description
  • Architecture document
  • Test plan / Test suite
  • Use cases (or other user-design tools)
  • Design documents (both high- and low-level)

Those documents are at least as important than the code, because they tell you what the code is supposed to do. The code just tells you what it currently does. Are you sure that what it does right now is correct? How much are you willing to bet?

Furthermore, most tools aren't able to use many of the reasons to use Perl in the first place. For example, I doubt a tool could reasonably handle

  • Array operations
  • Hashes in their non-trivial uses, especially as a way of passing named parameters
  • References (especially scalar, glob, and sub references)
  • Multiple return values from a subroutine
  • Context-aware subroutines
  • Complex data structures, especially dispatch tables and the like
  • Objects, in all their glory
  • The use of die, eval, and sub
  • Correct scoping of variables

I hope you really choose to do this by hand. It will take about 3-6 man-months to do it. (I'm not kidding - it won't take that long.)

We are the carpenters and bricklayers of the Information Age.

The idea is a little like C++ templates, except not quite so brain-meltingly complicated. -- TheDamian, Exegesis 6

... strings and arrays will suffice. As they are easily available as native data types in any sane language, ... - blokhead, speaking on evolutionary algorithms

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Comment on Re: Finding duplicated code in Perl
Re: Re: Finding duplicated code in Perl
by duff (Vicar) on Nov 26, 2003 at 15:02 UTC

    dragonchild, if I could ++ this node any more I would. So, consider this a virtual ++ x 100. :-)

    Although, you lose a few points because your signature is so long...*hint* *hint*

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (6)
As of 2014-07-29 00:56 GMT
Find Nodes?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:

    Results (211 votes), past polls