O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Errors

490 visualizações

Publicada em

How cognitive bias prevent you from using them on your day to day

Publicada em: Software
  • Seja o primeiro a comentar

  • Seja a primeira pessoa a gostar disto

Errors

  1. 1. ERRORS How they live, eat and reproduce Slides at https://bit.ly/gugu-talk-errors
  2. 2. ERRORS How cognitive bias prevent you from using them Slides at https://bit.ly/gugu-talk-errors
  3. 3. How I learned to program
  4. 4. What I wish I had been told
  5. 5. “Good judgement is the result of experience, experience is the result of bad judgement. Fred Brooks
  6. 6. Availability heuristic We expect things to work, ignoring the usefulness of error A biased prediction, due to the tendency to focus on the most salient and emotionally-charged outcome. Gabriel, P. Richard: The Rise of Worse Is Better
  7. 7. Treat errors and logs the same Assert, measure and don’t forget to learn!
  8. 8. Log messages have 10 parts
  9. 9. 1. Messages ● Choose one: ○ What happened? ○ What didn’t happen? ○ What should be done? ● DDD (the shit out of) them: ○ Make usage of ubiquitous language ○ The same error should always produce the same message (allowing to group them) Not easy to make them good, impossible if you don’t start using them
  10. 10. Day-to-day vocabulary
  11. 11. Error Emergency, Alert, Critical or Error A database drop, an update without “where”, hardware failure, resource stealing, an attack or an old lady scraping metal to sell… shit happens. When they happen, we usually have contingency. But there is a limit to it, so we act quickly on those - so they don’t become defects. 2001. Lonvick, C.: The BSD syslog Protocol (IETF RFC 3164)
  12. 12. Defect What customers should never face We never want end-users seeing errors. We know them as bugs, but using a more specific term for when end-users are affected speeds communication and resolution. 2008. Pryce, Nat: Throw Defect
  13. 13. Warning Notice, Info and Debugs Fixing bugs is also known as debugging, logs aid on that. Remember those `var_dump` calls? Make them log messages and use the severity based on the likelihood of defects happening because of them. 2001. Lonvick, C.: The BSD syslog Protocol (IETF RFC 3164)
  14. 14. 2. Contexts ● Important details: ○ When it happened? ○ Where it happened? ■ Application name ■ Environment ■ Hostname ○ Severity ○ Facility ● Details to aid debug: ○ User information ○ Stack trace ○ HTTP call being made ○ What file/line generated it? ○ Request ID ● Usually follow a filterable pattern The devil is on the details
  15. 15. Is this message Good or Bad?
  16. 16. Database error
  17. 17. @augustohp not found
  18. 18. Missing DB_DSN environment variable
  19. 19. 404: Page not found
  20. 20. Where can you find good error messages? ● Database error messages, care for how variable they are ● HTTP errors are few and precious, not a bingo ● PHP errors are very informative, care for variables as well
  21. 21. When to use variable messages? Be mindful of who they are for
  22. 22. 2002. Spolsky, Joel: The Law of Leaky Abstractions Hardware OS I/O Language Framework App Abstraction level
  23. 23. 2002. Spolsky, Joel: The Law of Leaky Abstractions Hardware OS I/O Language Framework App Errors “leak” from lower levels
  24. 24. If you aggregate every message....
  25. 25. Cry wolf You must never filter which error is relevant Anthropic bias is when evidence is biased by “observation selection effects”. You don’t want to base your assumptions over someone’s observation. 2012. Bostrom, Nick: Anthropic Bias - Observation Selection Effects in Science and Philosophy
  26. 26. Alert over frequency Monitorama EU 2013 - Lindsay Holmwood: Psychology of alert design
  27. 27. “Abstractions save us time working, not learning. Joel Spolsky
  28. 28. The PHP cookbook for Errors Dirty tricks for the day to day 2014. Pascutti, Augusto: Logs - O que eles comem, onde vivem e como se reproduzem
  29. 29. PHP Configuration
  30. 30. Development You want to see every nasty error ; php.ini display_errors = On error_reporting = -1 log_errors = On error_log = /var/log/php_error.log
  31. 31. Production Make them sexy, and log them ; php.ini display_errors = Off error_reporting = -1 log_errors = On error_log = /var/log/php_error.log
  32. 32. Chain exceptions
  33. 33. Create 2 base exceptions
  34. 34. 2008. Pryce, Nat: Generic Throws
  35. 35. Exception ideas
  36. 36. 2008. Pryce, Nat: Throw Defect
  37. 37. Exceptions are for exceptional cases C2 Wiki: Don’t use Exceptions For Flow Control
  38. 38. Use monolog (PSR-3)
  39. 39. Aggregate using Syslog 2001. Lonvick, C.: The BSD syslog Protocol (IETF RFC 3164)
  40. 40. “I would advise students to pay more attention to the fundamental ideas rather than latest technology. The technology will be out-of-date before they graduate. Fundamental ideas never get out of date. David Lorge Parnas
  41. 41. Conclusions ● Errors are not problems ● Treat them like logs ● Log eases debugging
  42. 42. Can I help you make more mistakes? Questions? Suggestions?! Beer time?
  43. 43. Credits ● Fonts in use are Ubuntu (Ubuntu) and Gentium Basic (Sil International) ● Theme is based on Solarized color-scheme by Ethan Schoonover

×