انتقل إلى المحتوى
أمين أبوزيد
BEG-018

تصحيح الأخطاء (Debugging)

  • 6 درس
  • 71 دقيقة قراءة
  • 3 ساعة تدريب (تقدير)
في هذه الصفحة 8 موضوعات

نص الدروس والتمارين باللغة الإنجليزية، بينما تبقى واجهة الموقع وعناوين الدروس بالعربية.

نظرة عامة

الموضوعات

  • نقاط التوقف (Breakpoints)
  • الدخول إلى/تخطّي/الخروج من (step into/over/out)
  • فحص المتغيرات
  • تتبّعات المكدس (stack traces)
  • الأخطاء الشائعة

تعلّم أولًا

71 دقيقة قراءة · 3 ساعة تدريب (تقدير)

مخرجات التعلم

  1. Set breakpoints (including conditional ones) and step into, over, and out in IntelliJ.
  2. Inspect and watch variables to find where actual behavior diverges from expected.
  3. Read a stack trace and navigate to the failing line.
  4. Apply a systematic process: reproduce, isolate, hypothesize, test, fix, verify.

الدروس

  1. 01منهجية لتصحيح الأخطاء12 د قراءة
  2. 02نقاط التوقف والتنقّل خطوة بخطوة12 د قراءة
  3. 03المتغيرات وقوائم المراقبة وتقييم التعبيرات (evaluate expression)12 د قراءة
  4. 04قراءة تتبّعات المكدس (stack traces)12 د قراءة
  5. 05فهرس لأخطاء وقت التشغيل الشائعة12 د قراءة
  6. 06عرض عملي: مطاردة خطأ كاملة من البلاغ إلى الإصلاح11 د قراءة

المختبر والتمارين

Lab

BEG-018-LAB1 · Bug hunt

Outcomes: 1–4 · Time: ~2 h You receive five small programs, each with one logic bug. For each, write a trail:

  1. Reproduction steps (input, expected, actual).
  2. Your hypothesis.
  3. The line found with the debugger (breakpoint, stepping, watches).
  4. The fix and how you verified it.

Acceptance: all five fixed with a written trail.

Exercises (assessment: live debugging demonstration, also part of the BEG graduation gate)

IDOutcomeTask
BEG-018-EX011Set a conditional breakpoint that stops only on iteration 50 of a 100-iteration loop, then step into, over, and out of a method call.
BEG-018-EX022Using watches, find where sum first differs from your hand-traced value in a given program.
BEG-018-EX033Read a provided stack trace: name the exception, the failing line, and the calling method.
BEG-018-EX044Write the six-step debugging process and apply it to "average prints the wrong value for [1, 2]".
BEG-018-EX053Match three exceptions (NullPointerException, NumberFormatException, ArithmeticException) to code that causes each.
أظهر الحلول
  • EX01 Right-click the breakpoint, enter i == 49 (or i == 50 depending on the loop start); use F8, F7, Shift+F8.
  • EX02 Add a watch for sum; compare it with your trace table on each pass; the first mismatch is the clue.
  • EX03 Read the first line for type and message, then the first line with your own class and its line number.
  • EX04 Reproduce with [1, 2]; isolate the average method; hypothesis integer division; test with a debugger watch; fix with (double) sum / count; verify with [1, 2] and [2, 4, 6].
  • EX05 String s = null; s.length(); Integer.parseInt("abc"); 5 / 0.
  • Outcome 4 is also assessed by the live debugging demonstration and the lab written trails.

الاختبار

Outcomes: O1 breakpoints and stepping · O2 inspecting variables · O3 stack traces · O4 debugging process.

اختبار ذاتي لك: لا توجد درجات، ولا يُحفظ أو يُرسل أي شيء. اختر إجابة ثم تحقق منها، ويمكنك المحاولة مرة أخرى كما تشاء.

  1. 1A breakpoint:O1
  2. 2"Step into" does what?O1
  3. 3A conditional breakpoint pauses:O1
  4. 4A watch is used to:O2
  5. 5When a variable's value surprises you, you should:O2
  6. 6In a stack trace, which line do you open first?O3
  7. 7Index 5 out of bounds for length 5 means:O3
  8. 8Integer.parseInt("abc") throws:O3
  9. 9The correct order is:O4
  10. 10Fixing the symptom rather than the cause means:O4

الجزء العملي

Five exercises BEG-018-EX01 to EX05 plus the five-bug hunt with written trails; the live debugging demonstration (also part of the BEG graduation gate) is assessed by the instructor. Pass: all five bugs fixed with trails and a successful live demonstration.

أخطاء شائعة

Changing code at random; adding print statements everywhere instead of breakpoints; fixing the symptom, not the cause.

التقييم

Live debugging demonstration (also part of the BEG graduation gate).

الصلة بالمسار الوظيفي

Grows into troubleshooting (JNR-054), profiling (MID-008), and incident handling (MID-050).

اكتب للبحث في المستويات والمراحل والوحدات والدروس.