Re: trouble creating array of objects
From: Richard Heathfield (dontmail_at_address.co.uk.invalid)
Date: 12/09/03
- Next message: wizbone: "reading og writing to com ports"
- Previous message: Maya: "About compilers"
- In reply to: Martijn Lievaart: "Re: trouble creating array of objects"
- Next in thread: Jumbo: "Re: trouble creating array of objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 9 Dec 2003 20:12:30 +0000 (UTC)
Martijn Lievaart wrote:
> On Tue, 09 Dec 2003 18:05:47 +0000, Gene Wirchenko wrote:
>
>>>When faced with this, I often decide to refactor. I already did before it
>>>became mainstream. I makes deciding easier, there is less risk involved.
>>>You can stop when sufficient bugs are squashed. You can regression test.
>>
>> I prefer to debug first. Get it right, then get it better. I
>> might try refactoring, but I would preserve the original in case I had
>> to fall back. The buggier the code, the less likely I am to refactor
>> first.
>
> Depends, but in general I don't agree. The buggier the code, the more
> difficult it is to get the bugs out. A little bit of refactoring can go a
> long end towards better code quality which makes debugging easier. (That
> is debugging as in getting the bugs out, not firing up the debugger).
Preliminary refactoring (the kind of tidying up of source that is common
here) can *eliminate* the need for debugging.
<saga>
In early 1990, I joined MumbleCo, a small insurance firm, and they taught me
a language called KMan, which was part of a wider expert system package
called Guru. They didn't hang about - I read the manual on Monday and got
to work on production code on Tuesday.
After I'd been there several months, I was asked to chase down a bug in an
Outstanding Losses report program (OSLOSS - nice name!). The program was
written in KMan, of course.
I read through the program, looking for obvious bugs. I couldn't see any,
but the code was a ***mess***. It was very, very, very badly written. In
fact, it was so badly written that it was effectively impossible to debug.
"Okay," I thought - "I'll just clean it up a little and then maybe I'll be
able to read it well enough to debug it. And *then* I'll track down the
original programmer and give him a good slapping."
So I backed up the source, and then went through the sort of review process
that those who use this newsgroup a lot will be familiar with - the moral
equivalent of gets() to fgets() and void main() to int main(). Once I'd
cleaned the code up, it looked a LOT better. Yes, I could debug this, I
think. So I plugged in the case data and stepped through the code. The bug
didn't appear. I ran it through the original code again. Yep, bug. New
code, no bug. Ha! So I was right in my hypothesis that my clean,
well-structured code was far superior, and far more robust, than the kind
of crap written by... whom?
I scrolled to the top of the source and read the intro block for the first
time, to read the programmer's name.
You're ahead of me, I know. Yes, it was me. My very first KMan production
program, written on that very first Tuesday.
</saga>
-- Richard Heathfield : binary@eton.powernet.co.uk "Usenet is a strange place." - Dennis M Ritchie, 29 July 1999. C FAQ: http://www.eskimo.com/~scs/C-faq/top.html K&R answers, C books, etc: http://users.powernet.co.uk/eton
- Next message: wizbone: "reading og writing to com ports"
- Previous message: Maya: "About compilers"
- In reply to: Martijn Lievaart: "Re: trouble creating array of objects"
- Next in thread: Jumbo: "Re: trouble creating array of objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|