Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Are Debuggers Crutches?

DZone's Guide to

Are Debuggers Crutches?

· DevOps Zone
Free Resource

Learn more about how CareerBuilder was able to resolve customer issues 5x faster by using Scalyr, the fastest log management tool on the market. 

Woman on CrutchesDefects are common, but they are not not necessary.  They find their way into code because:
Defects are only corrected by understanding pathways and debuggers are not the best way to do this.

Debuggers are commonly used by developer's to understand a problem, but just because they are common does not make them the best way to find defects.  I'm not advocating a return to "the good old days" but there was a time when we did not have debuggers and we managed to debug programs.

Avoid Defects

Personal Software ProcessThe absolute best way to remove defects is simply not to create them in the first place. You can be skeptical, but things like  the Personal Software Process (PSP) have been used practically to prevent 1 of every 2 defects from getting into your code.  Over thousands of projects:

The Personal Software Process increases productivity by 21% and increases code quality by 31%(1)


A study conducted by NIST in 2002 reports that software bugs cost the U.S. economy $59.5 billion annually. This huge waste could be cut in half if all developers focused on not creating defects in the first place.

Not only does the PSP focus on code planning, it also makes developers aware of how many defects they actually create.  Here are two graphs that show the same group of developers and their defect injection rates before and after PSP training.( 2)
Before PSP training After PSP training

One of the most enduring ratios in software development over 50 years is the ratio 1:10:100 which represents the relative cost of finding defects:
  1. Pre-test
  2. In QA
  3. In deployment (i.e. by the customer)
If you are primarily using debuggers to find defects then this is in QA or deployment, which makes your costs 10 to 100 times that of any pre-test defect removal strategy.  The pre-test defect removal strategies are those like planning, TDD, code-inspections, and design by contract.


It costs 10 to 100 times as much to find defects once they get to QA.

Finding Defects

Unskilled professionalUsing a debugger to understand the source of a defect is definitely one way.  But if it is the best way then why do poor developers spend 25 times more time in the debugger than a a good developer? (see No Experience Required!)

That means that poor developers spend a week in the debugger for every 2 hours that good developer does. No one is saying that debuggers do not have their uses.  However, a debugger is a tool and is only as good as the person using it.  Focus on tools obscures lack of skill (see Agile Tools do NOT make you Agile )

If you are only using a debugger to understand defects then you will be able to remove a maximum of about 85% of all defects, i.e. 1 in 7 defects will always be present in your code. Orkin manWould it surprise you to learn that their are organizations that achieve 97% defect removal? (3)

Software inspections take the approach of looking for all defects in code and getting rid of them. Learn more about software inspections and why they work here:

Software inspections increase productivity by 21% and increases code quality by 31%(1)


Even better, people trained in software inspections tend to inject fewer defects into code. When you become adept at parsing code for defects then you become much more aware of how defects get into code in the first place. But interestingly enough, not only will developers inject fewer defects into code and achieve defect removal rates of up to 97%, in addition:

Every hour spent in code inspections reduces formal QA by 4 hours

Conclusion

As stated above, there are times where a skilled professionalwill use a debugger correctly.  However, if you are truly interested in being a software professional then:
  • You will learn how to plan and think through code before using the keyboard
  • You will learn and execute software inspections
  • You will learn techniques like PSP which lead to you injecting fewer defects into the code

You are using a debugger as a crutch if it is your primary tool to reduce and remove defects.


Related Articles

Want to see more sacred cows get tipped? Check out: Make no mistake, I am the biggest "Loser" of them all.  I believe that I have made every mistake in the book at least once :-)

References

Find out more about how Scalyr built a proprietary database that does not use text indexing for their log management tool, allowing customers to search 1TB of data in under a second. 

Topics:

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}