Important Notice:

Debugging Techniques

Debugging Techniques

2 views 2 min read

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

a = 10
 b = 20
print("a =", a)
print("b =", b)
sum = a + b
print("sum =", sum)
 
Output :-
a = 10
b = 20
sum = 30
 

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 -

a = 10
b = 20
avg = a + b / 2
print(avg)
 
यदि Output 20 आता है, तो हम पीछे जाकर Formula की जाँच करेंगे।

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 -

a = 10
b = 20
c = 30

sum = a + b + c
avg = sum / 2

print("Average =", avg)
समस्या (Problem)

यहाँ Average गलत निकलेगा।

Output -

Average = 30.0

लेकिन सही Average होना चाहिए: 20.0

हम केवल उन लाइनों को देखेंगे जो avg को प्रभावित कर रही हैं:

sum = a + b + c

 avg = sum / 2

बाकी Lines (a, b, c, print) अभी Ignore कर सकते हैं।

Related Notes