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

Introduction to IDEs and Debugging

Introduction to IDEs and Debugging

Integrated Development Environments (IDEs) and Debugging – discover what the fuss is all about!

An IDE is a very powerful tool that helps you to understand your code. Imagine being able to jump to a function’s declaration, find all usages of said function, and even be able to step through the function line by line to truly understand what is happening in your program (and fix those pesky, hard to find bugs!).

For a long time I thought using a simple text editor like Sublime or Textmate was all a web developer needed. You make a code change, save the file, refresh your browser and it either works or it doesn’t!. If you wanted to be fancy you could even output your variables in a ‘var_dump’!

However, using ‘var_dump’ interjected in your code is not always the best solution (and would sometimes be impossible in an XMLRPC or delayed script), and relying on your editor’s ‘Find’ to search through your entire project to find a function’s declaration is disjointed and can be extremely time consuming.

We’ll walk through using and understanding an IDE (the basics) as well as run through how to set up and step through our code, line by line.

Just imagine, being able to stop at any point of execution in your code, walk line-by-line through it and at any point see what variables are alive and what values they hold. It’s analogous to taking the blindfold off and truly seeing (and understanding) your code.

Aaron Holbrook

June 15, 2014
Tweet

More Decks by Aaron Holbrook

Other Decks in Technology

Transcript

  1. Debugging is a process of finding and reducing the number

    of bugs in a computer program, thus making it behave as expected
  2. public function get_instagram_data( $parameter, $type = null ) { !

    var_dump( $parameter ); // Needed to see what parameter was passed ! $access_token = get_option( 'easy_instagram_access_token' ); ! if ( false === $access_token ) return false; ! var_dump( $access_token ); // Was it false? What was it? ! ! . . .
  3. protected function get_instagram_url( $parameter ) { ! $preg_match = preg_match(

    '/^(@|#)([a-z]+)/', $parameter, $matches ); var_dump( $preg_match ); // What was the result? var_dump( $matches ); // Any matches? ! if ( ! empty( $preg_match ) ) { ! ! . . .
  4. 1. USE IDE (Integrated Development Environment) 2. CONFIGURE 3. ENABLE

    XDEBUG 4. SET BREAKPOINT 5. LOAD PAGE 6. EXAMINE VARIABLES & WALK THROUGH CODE
  5. 1. USE IDE (Integrated Development Environment) 2. CONFIGURE 3. ENABLE

    XDEBUG 4. SET BREAKPOINT 5. LOAD PAGE 6. EXAMINE VARIABLES & WALK THROUGH CODE REPEAT STEPS 4-6 AS NECESSARY
  6. 1. USE IDE (Integrated Development Environment) 2. CONFIGURE 3. ENABLE

    XDEBUG 4. SET BREAKPOINT 5. LOAD PAGE 6. EXAMINE VARIABLES & WALK THROUGH CODE
  7. 1. USE IDE (Integrated Development Environment) 2. CONFIGURE 3. ENABLE

    XDEBUG 4. SET BREAKPOINT 5. LOAD PAGE 6. EXAMINE VARIABLES & WALK THROUGH CODE REPEAT STEPS 4-6 AS NECESSARY
  8. .2

  9. In computer science, a call stack is a stack data

    structure that stores information about the active subroutines of a computer program