Key Strategies in Software Debugging.
1. Understand the requirements well. Design the software well. Code well.
These will reduce the number of defects in your system.
2. Don’t use random guessing about defects. Use a systematic and scientific method to detect and fix bugs.
3. Identify the root cause of a defect. Understand the program and then try to solve
4. Set the compiler warning in it’s pickiest level. Solve all the issues as listed in the warning messages
5. Make wise use of debugging tools but use your brain in parallel.
Debugging? Is a process to find the cause of an error/issue/defect whereas testing is the process to find the error/defect in the first place.
Defects are opportunities for a good programmer. How? When you are a good programmer, you will code well.
Still if you have defects than something is missing somewhere, it will give you opportunities to learn many stuffs like:
1. Check: Did you understand the program/requirements?
2. Learn: what kinds of mistakes you make
3. Learn: how you solve problems4. How you fix defects
When you know your own patterns then there will be opportunities to improve yourself.
Bad ways to debug software:
1. Find defects by random guessing, by using print statements randomly.
2. Don’t try to understand the program just find the defect and fix
3. Use most obvious fix. You see the code does not work for 23 as input otherwise fine. So write a special case for 23
4. Debugging by superstition.
Finding a Defect
Scientific method of debugging
1. Stabilize the error through experiments. Be sure about the error and when it happens.
2. Gather the data through repeatable experiments that produces the defect
3. Form a hypothesis that states the cause of the error
4. Design experiments to prove or disprove the hypothesis.
5. Prove or disprove the hypothesis.
6. Repeat as needed
7. Fix the defect
8. Test the fix
9. Look for similar errors in your code.
Checklist for finding defects:
Reproduce the same error in several different ways.
Brainstorm for possible hypotheses
Use a notepad to list the things to try
Find the suspicious region of your code
Check the error-prone classes and routines
Check recently modified/added codes
Check for common defects
Check region by region. Expand your region after one region is covered
Talk to someone about the problem
Relax a bit. It works great sometimes.
Reference: Code Complete, 2nd Edition by Steve McConnel
From: http://sitestree.com/?p=4780
Categories:22
Tags:
Post Data:2006-11-06 07:32:26
Shop Online: <a href='https://www.ShopForSoul.com/' target='new' rel="noopener">https://www.ShopForSoul.com/</a>
(Big Data, Cloud, Security, Machine Learning): Courses: <a href='http://Training.SitesTree.com' target='new' rel="noopener"> http://Training.SitesTree.com</a>
In Bengali: <a href='http://Bangla.SaLearningSchool.com' target='new' rel="noopener">http://Bangla.SaLearningSchool.com</a>
<a href='http://SitesTree.com' target='new' rel="noopener">http://SitesTree.com</a>
8112223 Canada Inc./JustEtc: <a href='http://JustEtc.net' target='new' rel="noopener">http://JustEtc.net (Software/Web/Mobile/Big-Data/Machine Learning) </a>
Shop Online: <a href='https://www.ShopForSoul.com'> https://www.ShopForSoul.com/</a>
Medium: <a href='https://medium.com/@SayedAhmedCanada' target='new' rel="noopener"> https://medium.com/@SayedAhmedCanada </a>