Debugging Techniques (डिबगिंग तकनीकें) :-
Program में मौजूद Errors (त्रुटियों) को खोजने और उन्हें ठीक करने की प्रक्रिया को Debugging कहते हैं।
English:
Debugging is the process of finding and fixing errors in a program.
1. Brute Force Method :-
इस विधि में Program के विभिन्न स्थानों पर print() statements लगाकर Variables की Values को जाँचा जाता है।
English:
In this method, print() statements are inserted at different points to check variable values.
Example
Exam Point:
सबसे आसान और सबसे अधिक पूछा जाने वाला तरीका।
2. Backtracking Method :-
इस तकनीक में गलत Output से पीछे की ओर जाकर Error के स्रोत को खोजा जाता है।
English:
In this technique, the programmer traces backward from the incorrect output to find the source of the
Example -
3. Cause Elimination Method :-
इस विधि में Error के सभी संभावित कारणों (Possible Causes) की सूची बनाई जाती है और उन्हें एक-एक करके जाँचकर हटाया जाता है, जब तक कि वास्तविक कारण (Actual Cause) न मिल जाए।
English:
In this method, all possible causes of an error are listed and eliminated one by one until the actual cause is found.
उदाहरण (Example)
मान लीजिए Login Program काम नहीं कर रहा।
संभावित कारण (Possible Causes)
Username गलत है
Password गलत है
Database connection नहीं है
Internet/Network समस्या है
Server बंद है
अब इन कारणों को एक-एक करके जाँचेंगे।
4. Program Slicing
Program Slicing एक ऐसी Debugging Technique है जिसमें Program के केवल उस हिस्से (Part of Code) की जाँच की जाती है जो Error या गलत Output से संबंधित हो।
English:
Program Slicing is a debugging technique in which only the portion of the program related to the error or incorrect output is examined.
Example -
यहाँ Average गलत निकलेगा।
Output -
Average = 30.0
लेकिन सही Average होना चाहिए: 20.0
हम केवल उन लाइनों को देखेंगे जो avg को प्रभावित कर रही हैं:
sum = a + b + c
avg = sum / 2
बाकी Lines (a, b, c, print) अभी Ignore कर सकते हैं।