Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Art of Debugging @ Phpro Weekend 05/17

The Art of Debugging @ Phpro Weekend 05/17

Toon Verwerft

May 19, 2017
Tweet

More Decks by Toon Verwerft

Other Decks in Programming

Transcript

  1. Can  be  very  big Can  be  spread  across  many  files

    Can  be  spread  across  multiple  devices
  2. 1. Check  log  files 2. Try  to  reproduce  the  bug

    3. Go  through  the  code  step-­‐by-­‐step 4. Add  breakpoint  at  important  locations
  3. SINGLE  RESPONSIBILITY • One  class  has  one  responsibility • Use

     controllers  to  transform  the  request  in  a  response • Use  services  to  handle  business  logic • Use  data  managers  to  collect  /  store  data • Use  Events  to  trigger  side  actions • Use  validators  for  validation
  4. DEFENSIVE  PROGRAMMING • Enable  strict  types • Specify  all  argument

     types • Specify  return  type • Validate  state • Don't  be  afraid  to  throw  exceptions • Always  keep  track  of  the  unhappy  path
  5. CODE  CALISTENICS 1. Only  one  indentation  per  method 2. Do

     NOT  use  the  "else"  keyword 3. Wrap  all  primitive  types  if  it  has  behavior 4. Only  one  -­‐>  per  line 5. Do  not  abbreviate 6. Keep  your  classes  small 7. Limit  the  number  of  instance  variables 8. Use  first  class  collections