Why should programmers debug their own code?

Status
Not open for further replies.
Hello all,

I am facing the possibility of becoming the full-time debugger here at my office. The other programmers are "too busy" developing all these buggy programs to stop, go back, and fix their old bugs, so the job has been passed to me.

Personally, I hate debugging even my own code. To try and go into someone else's stuff, written with absolutely no coding standards whatsoever, and find why one little thing isn't working right seems to be a new layer of hell.

In college I seem to remember my teacher telling us that it is much more time efficient for programmers to debug their own code. And while this makes logical sense to me, I have been trying to find this documented somewhere online and failed. See, I want to present this as a time-saving suggestion to the boss, to make everyone debug their own code, but I need reasons why.

So can you all please help me and tell me reasons why programmers should debug their own code? Even better would be references to official documentation saying that it is much more efficient.

Chambers
 

HL7

Ars Praefectus
3,523
Subscriptor++
Originally posted by Chambers:
In college I seem to remember my teacher telling us that it is much more time efficient for programmers to debug their own code.
Well, in college, I learned that code is usually debugged better when it is reviewed by someone other than the original programmer. (Obviously one of many areas in CS where there is no consensus).

So can you all please help me and tell me reasons why programmers should debug their own code? Even better would be references to official documentation saying that it is much more efficient.
Actually, I think you'll find more documentation supporting the idea that code should be reviewed by a separate debugging and testing team. While it may be more efficient in terms of time, it is that very efficiency that will cause programmers to miss faults. When a programmer reads his own code, he will tend to read it as "what I mean for this code to do," even if the code is wrong and doesn't do what is intended. But someone else reading the code will be figuring it out as they go, and thus will tend to read "what this code actually does." Thus the independent reviewer is more likely to catch the faults.

If your programmers are constantly churning out buggy code, then it's time to take a look at your design & analysis phase and make sure things are being planned out carefully.
 
Just to clarify further,

I'm not talking about testing. There are different people than us who test and put the bugs they find in our bug database. I am just talking about going into the database, seeing a bug, and going to try and fix it.

I think with testing and *findng* new bugs you are very right and a new person looking at the code with new eyes is a great help, but I think that no one can go into a program and *fix* a problem better than the person who originally wrote it.

-Chambers

P.S. Oh and "design and analysis phase"? HAHAHAHAHA I WISH The million-dollar project was due months ago and they are just now nailing down exactly what will be delivered. Who is the customer who has already paid over a million dollars for such incompetency? You guessed it, the federal government. Anyway, the way this office is run is a completely different problem and I am the newest person here (also the only one with any computer education who speaks english) and so in no position to change things. yet.
 

Prototyped

Ars Legatus Legionis
11,126
Having someone else debug one's code is a rather bad idea, and an example of mismanagement, primarily because the troubleshooting maintenance programmer will have to gain familiarity with the code — familiarity that the programmer who wrote the code already has. This will mean that bugs will take much longer to get fixed, because now someone has to learn how the code works in order to fix the bugs.

It's fine to have a QA team do testing — including automated regression tests — and find bugs — they're not concerned with knowing how it works and how to fix it, only that it ought to work as specified. However, maintenance ought to be done by the author because of familiarity, best knowledge of design and implementation decisions, knowledge of impact on other components, etc.
 

DaemonBlood

Ars Tribunus Militum
2,294
Testing is a completly different aspect and I think programs should be tested by a 2nd party.

I wholy agree with you for the debugging aspects though, and being in your postition really would be pretty awefull.

I'll try and list a few reasons as to why it's not time effcient.

1. Program interpretation. A seperate party would have to first understand what the original programer was intending and then try to fix any bugs that might be present in the program.

2. Program mis-interpretation. If the above program is not interpreted correctly, or if any part of the above program is not interpreted correctly, the code could get even more buggy/misdirected.

3. What happens if the bug actually turns out to be a flaw in the implementation. Then everyone has to go back, rewrite the flawed software, and rewrite everything that used the flawed software.

4. Lazy programmers. Problems could just be writen off as bugs and passed down the line. When programmers dont have to be held accountable they can get away with whatever they want.

Thats just a few thoughts that come to mind, im sure there are a lot more.
 

Horatio

Ars Legatus Legionis
24,430
Moderator
Let me be a little clearer on how things work here. Programmers are responsible for their own bugs, until the product ships. Then, they tend to move on to the next rev, or another product or whatever. Inevitably, there will be bugs in the released product, which is the responsiblilty of the sustained engineering team. It's their job to take bugreports, and have them fixed. Sometimes they go to the original programmer, but often, they do it themselves. The system works. It really does.
 

HL7

Ars Praefectus
3,523
Subscriptor++
Originally posted by Chambers:
I'm not talking about testing. There are different people than us who test and put the bugs they find in our bug database. I am just talking about going into the database, seeing a bug, and going to try and fix it.
I see. Yes, I agree that programmers should be responsible for actually fixing the bugs. If during the testing process, an error has been found, it should be up to the original programmer to fix the fault.

As for finding the fault, this responsibility may or may not be divided between the two. e.g., the testing team may simply say "your program causes an error on this input," or someone could actually track it down to the module or function that is causing the error. But the original programmer should be responsible for fixing the code (unless, of course, it's been passed off to a maintenance programmer, as it is in Horatio's organization). It sounds like your orginzation is trying to set up such a system, with you as the maintenance programmer.

No one likes maintenance. But it is the largest part of software's life cycle, so you would be doing the most important programming job there, even if no one sees it that way. ;)

P.S. Oh and "design and analysis phase"? HAHAHAHAHA I WISH
Unfortunately, this is what will really fix things if your programmers churn out fault-ridden code. Ad-hoc coding may work for a 2,000 line program, but if it's a million-dollar project, it had better have some design & analysis. Obviously, you're seeing the reason first-hand. :(
 

jbode

Ars Legatus Legionis
11,752
Subscriptor
Originally posted by Chambers:
Hello all,

I am facing the possibility of becoming the full-time debugger here at my office. The other programmers are "too busy" developing all these buggy programs to stop, go back, and fix their old bugs, so the job has been passed to me.

I need some clarification on this. Are you talking about fixing bugs found in unit or integration testing, bugs found by QA prior to shipment, or defects reported by customers after shipment?

Personally, I hate debugging even my own code. To try and go into someone else's stuff, written with absolutely no coding standards whatsoever, and find why one little thing isn't working right seems to be a new layer of hell.

In college I seem to remember my teacher telling us that it is much more time efficient for programmers to debug their own code. And while this makes logical sense to me, I have been trying to find this documented somewhere online and failed. See, I want to present this as a time-saving suggestion to the boss, to make everyone debug their own code, but I need reasons why.

Well, I know the project I am on has been delayed several times because the lead developer has had to put out fires caused by problems in earlier versions. This guy is probably the sharpest developer I've ever worked with, and any bugs in his code are subtle and often take days to figure out (he doesn't make the stupid, easy-to-find mistakes that I tend to). He's a critical resource for developing new products, and having him spend a week tracking down a bug that turns out to be a subtle interaction between the product, the OS command shell, and a particular customer's configuration is not an efficient use of his time. We're not big enough that we can afford to miss too many ship dates. Unfortunately, we don't have a full-time maintenance staff (and never will).

I've been on both sides of the fence, and I won't dispute that new development beats hell out of maintenance. However, if you're continued survival means putting something new out every quarter or so, you have to have a dedicated maintenance team. If you have your original developers patching defects, they'll never get anything new out the door.

So can you all please help me and tell me reasons why programmers should debug their own code? Even better would be references to official documentation saying that it is much more efficient.

Chambers

Sorry, but I don't agree with your premise. From a business point of view, it isn't efficient at all.
 

HL7

Ars Praefectus
3,523
Subscriptor++
Originally posted by jbode:
However, if you're continued survival means putting something new out every quarter or so, you _have_ to have a dedicated maintenance team. If you have your original developers patching defects, they'll never get anything new out the door.
Good point. But it sounds as if he's going to be responsible for fixing defects in a current project as it's being written, which is a different scenario.
 
I need some clarification on this. Are you talking about fixing bugs found in unit or integration testing, bugs found by QA prior to shipment, or defects reported by customers after shipment?

Well I think that the problem is that we have none of those phases. There only is and has only ever been one phase to this project, which is programming it. While we are programming different parts, a tester here will go through previously done parts and test them, and then we go back and fix those bugs and continue on. There is no unit or integration testing, and there is no QA.

The three of us are working on one large project, and they have just moved ahead to a different-ish part of the project and left some earlier sections they did behind. As far as I know the customers have not even seen this project yet.

I think the original deadline was sometime before I was hired about six months ago. It has been extended several times since, and I don't really know when or if there is a real one besides "when we get it done."

So from what I am hearing from all of you, and my past tiny bit of experience in the programming work force, I think that this software development department is as badly managed as I suspected. But when your customers have no idea if you are good or bad and the manager(s) don't have enough computer training to really know if they are good or bad, then how are they supposed to fix themselves and start acting like professional software developers.

I guess the programming isn't as bad as their whole process of software development, or rather *not* having a process, or even knowing that there is a more-or-less universally accepted process. This is because none of them has taken a class, read a webpage, or learned one bit about software development.

Okay I guess I answered my own question. The problem lies deeper than me having to fix other people's problems all day, and so perhaps it will not be fixable by me or anything I can do.
 

jbode

Ars Legatus Legionis
11,752
Subscriptor
Urgh. Okay, now I understand the problem. I've been in this movie too, and it wasn't pretty. In this case I agree, the original developers should be responsible for fixing their code before moving on. Unfortunately, it won't happen. What matters now is getting something, anything shipped, regardless of the condition it's in, so the focus is going to be on getting it coded and out the door ASAP. It sucks, but at this point there isn't a whole lot you can do besides ask for a reassignment or look for another job.
 

MrMills

Ars Praefectus
3,727
Moderator
HL7:
Good point. But it sounds as if he's going to be responsible for fixing defects in a current project as it's being written, which is a different scenario.
Note: Chambers isn't a 'he'. :)

PeterB:
IME, good comments are not sufficient to allow one to effectively deal with diabolical design.
Not only that; IME, bad programmers are also bad and inconsistent commenters.

i++; // increment i

etc.
 

HL7

Ars Praefectus
3,523
Subscriptor++
Originally posted by PeterB:
IME, good comments are not sufficient to allow one to effectively deal with diabolical design.
No, they're not. But even well-written code can seem diabolical if the programmer's intent isn't communicated through comments.

Note: Chambers isn't a 'he'.
Sorry, I don't ever bother to check.
 
The reasons to have coders review their own stuff have been mentioned already. Basically they're the same as the reasons you have them write code in the first place: when you get to the point of saying, "What is this shit code? It would be easier for me to rewrite this guy's stuff from scratch!", then it should be obvious you're doing ALL of his job and he's deadweight to the company.

There are reasons for other people the review code too: to cross-pollinate ideas, to cultivate a certain discipline or consistency in style, commenting, etc., also just to have "fresh eyes" catch your dumb errors. But that's not what you're talking about.

In part this varies depending on what you are programming, and on your support requirements. It sounds like you're in the middle of a haphazard assembly of coders trying to crank out "the first big'un", with not much continuing support req's. It sounds like they're trying to seat you with responsibility for their errors because they see potential failure looming. Don't get suckered.

I used to work for a broadcast software company. When you have a system controlling somebody's radio station, it cannot go down on your head. When one minute is worth $1000 in advertising, you can see why even a little downtime won't cut it. So, the idea that you could "crank out" code and leave it for somebody else to debug is a joke. The "somebody elses" are doing hardware/driver compatability, network integration, burn-in tests (sometimes weeks long). Working out those bugs. Passing them code that you know is faulty is a waste of time.

If you are expected to constantly clean up (or we'll be nice and say "integrate") their code, you must insist on thorough and lucid documentation.

Good luck
-joe
 

AlphaMeridian

Ars Legatus Legionis
17,136
Moderator
i++; // increment i

I would laugh at this depending on the level of the programmer. If it's a newbie programmer, Okay. He can go ahead and do it. For example, I'm going to create the "General Linked List Struct of DOOM" soon, and since this is my first (and only time) through, i'd likely put a whole lot of ass comments in there (Well, its my first time, and I need to know what each line does because I need to be able to modify it for the professors who don't want me to use more sane data types)

But for a pro, i++; //icrement i is.....well, it's childish :D

-Alpha
 

warmachine

Ars Tribunus Militum
2,479
Subscriptor
Chambers wrote:
I am facing the possibility of becoming the full-time debugger here at my office. The other programmers are "too busy" developing all these buggy programs to stop, go back, and fix their old bugs, so the job has been passed to me.

IMHO, this is a sign that your manager hates you. If you can debug their code fater than they can debug it themselves, you're far better than the developers. Yet their time is apparantly more valuable than yours. Leave.
 

skriefal

Ars Scholae Palatinae
1,056
That wouldn't be half as funny if I hadn't seen it a zillion times already.....

He works for you, too? :)

Here's another:
Code:
if ( A ) {
   ...
} else {
   // do nothing
}
And yes, I've seen plenty of examples of code which really do have comments proclaiming "// do nothing" or "// do nothing here". Apparently someone (or multiple someones) actually thought this made sense for some odd, perverted reason...
 

Tim L

Ars Legatus Legionis
14,039
Subscriptor
if ( A ) {
...
} else {
// do nothing
}

This is quite common when dealing with multiple conditions and is usually to indicate that the else condition is never expected to be executed, since the preceding conditions supposedly cover all bases. It's good practice IMO as it shows that the programmer didn't simply forget to write that part.
 

MrMills

Ars Praefectus
3,727
Moderator
This was taken from one of my coworkers' programs:

<div style="font-size:larger;font-family:monospace">
hours = int(intValue/60)
mins = (intValue mod 60)
If mins > 0 and mins < 15 Then
hours = hours + 0
ElseIf mins >= 15 and mins < 45 Then
hours = hours + 0.5
Else
hours = hours + 1
End If
' If there is only a little time left [< 15 mins) defalt to 0.5 hours.
If hours = 0 Then hours = 0.5
If hours = 1 Then
timeLeft = hours & " hour"
Else
timeLeft = hours & " hours"
End If
</div>

Now I've seen bad code, and I've seen comments to do nothing, but I'd never seen someone add zero to a number before. That was just odd.
 
but I'd never seen someone add zero to a number before.
Well it shows the clear choice between 0, 0.5, and 1. In a sense, it's not that stupid.
I usually go for something like //This should never execute.
Why not go for some kind of assertion instead? If it shouldn't execute, it'd be nice to know if it ever does. And assertions are self-commenting.
 
Programmers really shoulden't be testers.
Testers really should be potential programmers.
Programmers should fix their damn mistakes themselves, otherwise they will keep making the same stupid ones over and over again.

I was in a shop where I would do my own programming, and the other three programmers would pass off their shoddy code to me to test and bugfix. they managed to talk to the president of the company into having me test and fix their code.. In the end they kept making all the same mistakes over and over again and didn't care cause they didn't have to fix them.

IMO: testing should be done by someone else rather than the programmer, but the programmers should fix their own bugs.
 
Status
Not open for further replies.