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

Debugging as a Key Skill - WCSOF - WCMIL

Debugging as a Key Skill - WCSOF - WCMIL

My talk from WordCamp Sofia 2015 and WordCamp Milano 2016 about why, as a developer, you should treat debugging as a key skill that you should practice and become proficient at. I talk about some tools and processes for modern and efficient debugging of the front end and the back end, and how processes such as testing and version control can aid your debugging.

Video: https://wordpress.tv/2015/12/07/john-blackbourn-debugging-as-a-key-skill/

#xdebug #wordcamp #php #wcsof #wcmil #git #wordpress

John Blackbourn

October 22, 2016
Tweet

More Decks by John Blackbourn

Other Decks in Technology

Transcript

  1. Debugging as a Key Skill or Why var_dump() isn’t good

    enough John Blackbourn WordPresser at Human Made Ltd WordCamp Sofia 2015
  2. John Blackbourn • WordPress core developer • Senior engineer at

    Human Made • Find me on Twitter, GitHub, WordPress.org, etc: @johnbillion WordCamp Sofia 2015
  3. Dumping data to the screen in order to debug it

    isn’t appropriate in many cases.
  4. • Admin area • AJAX calls • REST API calls

    • XML-RPC calls • Media manager • RSS feeds • Cron events • The list goes on…
  5. Breakpoints A point at which code execution gets paused so

    its state can be inspected (with an external client of your choice)
  6. $ git bisect start $ git bisect good “2.6.10” $

    git bisect bad 4e05243 Bisecting: 74 revisions left to test after this (roughly 6 steps). [c20280a] Further tweaks to QM's output if JavaScript isn't available for any reason.
  7. $ git bisect start $ git bisect good “2.6.10” $

    git bisect bad 4e05243 Bisecting: 74 revisions left to test after this (roughly 6 steps). [c20280a] Further tweaks to QM's output if JavaScript isn't available for any reason. $ git bisect bad Bisecting: 36 revisions left to test after this (roughly 5 steps). [a59860e] Correct some output priorities.
  8. $ git bisect good Bisecting: 18 revisions left to test

    after this (roughly 4 steps). [c5f91e4] Consistent and correct output for closures and anonymous functions.
  9. $ git bisect good 6b3c8c2 is the first bad commit

    commit 6b3c8c2 Author: John Blackbourn Date: Mon Mar 16 00:27:08 2015 +0000 Don't add a warning indicator to the admin bar menu if the `all` hook is in use. The warning in the Hooks output is sufficient.
  10. $ git diff 1bd84ab 6b3c8c2 - public function admin_menu( array

    $menu ) { - $data = $this->collector->get_data(); - $args = array( - 'title' => $this->collector->name(), - ); - $menu[] = $this->menu( $args ); - return $menu; - } $ git bisect reset Previous HEAD position was 6b3c8c2... Don't add a warning indicator to the admin bar menu if the `all` hook is in use. Switched to branch 'master'
  11. Ever dealt with API calls to a third party? •

    Payment gateways • Pushing content to social media • Pulling from external sources Even indirectly via someone else’s plugin? Why?
  12. • Breakpoints in PHP with Xdebug • Breakpoints in browser

    dev tools • Investigating regressions with git bisect • Debugging server-side HTTP requests • Debugging sites on mobile devices Recap
  13. Debugging as a Key Skill Much of a developer’s time

    is spent reading, inspecting, and debugging, in addition to writing code. It makes sense that becoming proficient at debugging code should be as important as becoming proficient at writing it.