ZSI / Ladenie

Ladenie

Základy softvérového inžinierstva

Sergej Chodarev (sergejx.net)

Píšte kód bez chýb!

The End

Ale chyby sa stávajú

A Bug

Debugging

Prevencia

There are two ways to write code:
write code so simple there are obviously no bugs in it,
or write code so complex that there are no obvious bugs in it.

Tony Hoare

Zbierať informácie

Zaznamenávanie chýb

Logging

Nástroje

Čo s rastúcim súborom?

Log rotation

Čo ak aj tak vznikne chyba?

Don’t Panic

This is true for galactic hitchhikers and for developers.

The Pragmatic Programmer

Čo potrebujeme?

Proces

  1. Reproduce
  2. Diagnose
  3. Fix
  4. Reflect

1. Reproduce

Generally, if you can’t reproduce it, it’s almost impossible to fix.

— Anonymous programmer, Practices of Software Maintenance, Janice Singer

Reprodukovať

Zjednodušiť replikáciu

Failing Test Before Fixing Code

Create a focussed test that reveals the bug before you try fixing it.

The Pragmatic Programmer

2. Diagnose

Read the Damn Error Message

Most exceptions tell both what failed and where it failed. If you’re lucky you might even get parameter values.

The Pragmatic Programmer

Vedecká metóda

Instrumentation

Heisenbug

Divide and Conquer

Porovnanie verzií

Sústreďte sa na rozdiely

Debugger

Debugger

3. Fix

Fix

4. Reflect

The six stages of debugging

  1. That can’t happen.
  2. That doesn’t happen on my machine.
  3. That shouldn’t happen.
  4. Why is that happening?
  5. Oh, I see.
  6. How did that ever work?

Reflexia

Záver