Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: The worst thing...

by Aristotle (Chancellor)
on Oct 13, 2005 at 09:03 UTC ( #499823=note: print w/replies, xml ) Need Help??

in reply to The worst thing..
in thread Spaghetti code...

It depends.

Hateful as spaghetti code may be, there’s also the plain fact that it has worked in production for a while and has accumulated various bug fixes too. If you start over from scratch, you have to redo everything, including the parts which happen to be decent (which is the majority of the code even in most “bad” codebases), and you will likely run into half of the same bugs all over.

You are almost always better off refactoring the spaghetti code iteratively as you work on it. Instead of adding just one more hack to make something work and deferring the proper implementation for later, clean up that one corner of the code you’re directly working on, as far as is sanely possible, and add your change on top of that. The right way to do this, of course, is by writing tests for the part of the code you are about to clean up, so you can be confident that your cleanup doesn’t break anything. Over time, the codebase will slowly tend towards sanity, and as you go along you will progressively accumulate a test suite that will give you confidence to attack the code more aggressively in the more seriously broken parts.

Most of this work is quite mechanical.

Very few codebases are so hairy and disastrous that throwing away the good and known working parts they contain is justified.

Makeshifts last the longest.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://499823]
choroba played with the band on Saturday, so Sunday was very sleepy
[choroba]: managed to release Syntax::Construct with 5.28 support in the night, though
[Corion]: choroba: Whee ;)
[Corion]: marto: Ouch - I would've thought that kids adapt much better, but that's obviously not the case...
[marto]: well, their mother let them sleep till 15:00 & 12:00 last week, which didn't help them adjust :P
[Corion]: I was "productive" over the weekend in the sense that I revived my old "Perlmonks on SQLite" code, which likely means I can get a test instance back up running on my webhost. Small steps :)
[Corion]: marto: Ow, no, that doesn't help at all :)
[choroba]: Related to the new release, anyone could explain this or this tester report?
[Discipulus]: hello crew! marto thanks for the message: but I how can I help? i'm testing cpan Padre atm problem with Client::Debug
[choroba]: I don't happen to have 5.10.0 nor 5.8.5 handy...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (13)
As of 2018-06-25 08:37 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (126 votes). Check out past polls.