SlideServe
Menu
Préférences
© SlideServe · v2026

debugging, bug finding and bug avoidance Part 2

acton avatar
17 diapositives · 374 Views · Aug 20, 2014

debugging, bug finding and bug avoidance Part 2. Alan Dix www.hcibook.com/alan/teaching/debugging/. outline. part 1 – general issues and heuristics part 2 – the system as it is understand and document part 3 – locating and fixing bugs part 4 – bug engineering

debugging, bug finding and bug avoidance Part 2 - slide 1
01 / 17debugging, bug finding and bug avoidance Part 2
1 / 17

Télécharger la présentation

debugging, bug finding and bug avoidance Part 2
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. debugging, bug finding and bug avoidancePart 2 Alan Dix www.hcibook.com/alan/teaching/debugging/

  2. outline • part 1 – general issues and heuristics • part 2 – the system as it is • understand and document • part 3 – locating and fixing bugs • part 4 – bug engineering • design to expose, avoid and recover • including fail-fast programming

  3. debugging – part 2 the system as it is understand your system make assumptions explicit document interactions

  4. understand your system • collaborative walkthrough • personal walkthrough • what do you think it does? • print statements • what it really does! • make assumptions explicit • make interactions explicit

  5. d = (b3<<24) + (b2<<16) + (b1<<8) + b0; understand your systemwhen in doubt • document s = s.substring(idx+1); // +1 to skip current char • bracket d = b3<<24 + b2<<16 + b1<<8 + b0;

  6. understand your systembugs are where you’d expect • what was difficult to code?look there! • where would you expect errors?look there!

  7. understand your systembugs are where you’d expect • some years ago ... • testing third party floating point library • try simple case 1+2=3 – OK • try cases to force 16 bit carry – FAIL • soon after - problem with Microsoft C • 32 bit integer subtract • carry error  answer is 65536 out  

  8. understand your systembeginnings and endings • starting up • loading data (files exist, in right format?) • initialisation (doing it, doing it right, in the right order) • ending • saving data • releasing resources • closing/flushing files

  9. make assumptions explicitbad - implicit assumption int len(String str) { return str.length(); } • fails if str is null

  10. make assumptions explicitbetter - documented /** * @param str - must not be null */ int len(String str) { return str.length(); }

  11. make assumptions explicitdefensive - recover /** * @param str - must not be null */ int len(String str) { if ( str == null ) return 0; return str.length(); }

  12. make assumptions explicitdiagnostic - log /** * @param str - must not be null */ int len(String str) { if ( str == null ) { log(“len: str is null”); return 0; } return str.length(); }

  13. document interactions • external interactions (real world effects!) • mouse events, robot controls • sequence information • order of events, method calls • shared data • static variables, references to objects • hidden effects • influence on other objects / components

  14. document interactionsexternal interactions • say what causes events e.g. a component receives a MOUSE_PRESS event when and only when the user presses down a mouse button over it • N.B. not true of all Java AWT toolkits! • say what happens in the real world e.g. the move(x,y) method sends a signal to the robot arm control motor moving it x cm in the X direction and y cm in the Y direction

  15. document interactionssequence information • define events order explicitly e.g. MOUSE_PRESS and MOUSE_RELEASE events always alternate in the event sequence for any mouse button • N.B. not true of all Java AWT toolkits! • explain restrictions on method calls e.g. always call the xinit() method before other methods and call the close() method last • but check inside your code

  16. document interactionsshared data  hidden effects • can be difficult to describe e.g. if you create a TCP/IP socket in Java, what happens to the output part if you close the input? answer: it gets closed too object A object B reference reference object C

  17. document interactionsscenarios • typical paths through system • a ‘story’ about the system • what happenswhich objects involvedhow they affect data • several levels of detail e.g. see aQtive documentation at:http://www.aqtive.net/developer/developers-pack/onCue-hiw/onCue-hiw.html