Debugging It is what you do. Debugging Where your time is spent: 1 st place: documentation 2 nd place: debugging Most valuable skill: Debugging!

Slides:



Advertisements
Similar presentations
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 7 - JavaScript: Introduction to Scripting Outline 7.1 Introduction 7.2 Simple Program: Printing.
Advertisements

Chapter 3: Editing and Debugging SAS Programs. Some useful tips of using Program Editor Add line number: In the Command Box, type num, enter. Save SAS.
Interactive Media and Game Development Debugging.
Georgia Institute of Technology DrJava Appendix A Barb Ericson Georgia Institute of Technology May 2006.
Firefox Addon development tutorial 谢烜
Web Development in Microsoft Visual Studio Slide 2 Lecture Overview Introduce Visual Studio 2013 Create a first ASP.NET application.
The IDE (Integrated Development Environment) provides a DEBUGGER for locating and correcting errors in program logic (logic errors not syntax errors) The.
Tutorial 10 Programming with JavaScript
How to Debug VB .NET Code.
JavaScript Lesson 1 TBE 540. Prerequisites  Before beginning this lesson, the learner must be able to… Create a basic web page using a text editor and/or.
JavaScript, Fourth Edition
Formula Auditing, Data Validation, and Complex Problem Solving
XP Tutorial 1 New Perspectives on JavaScript, Comprehensive1 Introducing JavaScript Hiding Addresses from Spammers.
 JavaScript is a programming language that web browsers understand. You can use it to make your web pages interactive by: Responding to user actions and.
JavaScript Development Tools Front-End Development.
Debugged!.  You know that old line about an ounce of prevention?  It’s true for debugging.
Debugging JavaScript CS346. IE Javascript Debugging Aids From IE6 on default: no debugging aid for Javascript Change setting: – Tools > Internet Options.
WaveMaker Visual AJAX Studio 4.0 Training Troubleshooting.
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
1 Test Automation For Web-Based Applications Selenium HP Web Test Tool Training Portnov Computer School.
Selenium Web Test Tool Training Using Ruby Language Discover the automating power of Selenium Kavin School Kavin School Presents: Presented by: Kangeyan.
© 2012 LogiGear Corporation. All Rights Reserved Robot framework.
Ku-Yaw Chang Assistant Professor, Department of Computer Science and Information Engineering Da-Yeh University.
WEEK 3 AND 4 USING CLIENT-SIDE SCRIPTS TO ENHANCE WEB APPLICATIONS.
Structured programming 4 Day 34 LING Computational Linguistics Harry Howard Tulane University.
CSC 330 E-Commerce Teacher Ahmed Mumtaz Mustehsan Ahmed Mumtaz Mustehsan GM-IT CIIT Islamabad GM-IT CIIT Islamabad CIIT Virtual Campus, CIIT COMSATS Institute.
Javascript. Outline Introduction Fundamental of JavaScript Javascript events management DOM and Dynamic HTML (DHTML)
1 JavaScript in Context. Server-Side Programming.
Tutorial 10 Programming with JavaScript. XP Objectives Learn the history of JavaScript Create a script element Understand basic JavaScript syntax Write.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Python From the book “Think Python”
CPSC1301 Computer Science 1 Overview of Dr. Java.
Extending HTML CPSC 120 Principles of Computer Science April 9, 2012.
Our Environment We will exercise on Microsoft Visual C++ v.6 We will exercise on Microsoft Visual C++ v.6 because that is what we have in the univ. because.
Active-HDL Interfaces Debugging C Code Course 10.
Testing. 2 Overview Testing and debugging are important activities in software development. Techniques and tools are introduced. Material borrowed here.
Browsers © Copyright 2014, Fred McClurg All Rights Reserved.
FireBug. What is Firebug?  Firebug is a powerful tool that allows you to edit HTML, CSS and view the coding behind any website: CSS, HTML, DOM and JavaScript.
Chapter 3 The Visual Basic Editor. Important Features of the VBE Alt-F11 will open the Visual Basic Editor. The Code window is to the right, Project Explorer.
JavaScript, Part 2 Instructor: Charles Moen CSCI/CINF 4230.
1 SEEM3460 Tutorial Compiling and Debugging C programs.
JavaScript Introduction.  JavaScript is a scripting language  A scripting language is a lightweight programming language  A JavaScript can be inserted.
Guide to MCSE , Enhanced1 Activity 11-1: Using Task Manager to Manage Applications and Processes Objective: To explore managing applications and.
1 JavaScript in Context. Server-Side Programming.
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
IE Developer Tools Jonathan Seitel Program Manager.
Javascript Intro Instructor: Shalen Malabon. Lesson Plan Core Javascript Syntax Types and Objects Functions DOM Event Handling Debugging Javascript Smarter.
JavaScript, Sixth Edition
Tutorial 10 Programming with JavaScript. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Learn the history of JavaScript.
PHP (cont.). 2 Functions Definition – function name(arguments){... } –syntax name as for a variable, but without $ arguments as for variables –to return.
Chapter 4 Murach's JavaScript and jQuery, C4© 2012, Mike Murach & Associates, Inc.Slide 1.
Debugging No readings. 2 What's The Proper Indentation? function max(x,y) { if (x
Customizing Menus and Toolbars CHAPTER 12 Customizing Menus and Toolbars.
CIS 133 Mashup Javascript, jQuery and XML Chapter 8 Debugging and Error Handling.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
© 2010 Robert K. Moniot1 Chapter 6 Introduction to JavaScript.
BIT116: Scripting Lecture 06
Appendix A Barb Ericson Georgia Institute of Technology May 2006
© 2016, Mike Murach & Associates, Inc.
Chrome Developer Tools
Important terms Black-box testing White-box testing Regression testing
CIS 133 Mashup Javascript, jQuery and XML
Important terms Black-box testing White-box testing Regression testing
Compile, Build, and Debug
Due Next Monday Assignment 1 Start early
Our Environment We will exercise on Microsoft Visual C++ v.6
How to debug a website using IE F12 tools
Presentation transcript:

Debugging It is what you do

Debugging Where your time is spent: 1 st place: documentation 2 nd place: debugging Most valuable skill: Debugging!

"Poor Man's" debugging Find how to OUTPUT (print) variables alert( this ); console.log( this ); //need dev tools Find out how to INPUT (type or choose) prompt( this );

Techniques A few formal approaches

Science Experiments Guess (theory) Change something (variable) Run it (experiment) repeat the trial and error could be formal or informal

Test Cases Program testing code Recycle your experiments! Repeatable Automate repetitive tests Do stress testing Test Driven Design (TDD)

//buggy code: var dog; function bad_dog(){ dogg= "woof"; } //test case #1: bad_dog(); if( ! dog ){ alert( 'dog was not set' );}

assertions test cases PUT INTO THE PROGRAM preconditions check that things are as you expect postconditions check that result is as expected Not popular for scripting / runtime

function average(){ if(arguments.length==0){ throw('nothing to average!');} var total=0; for(i=0; i<arguments.length; ++i){ total+= arguments[i]; } return total / arguments.length; } average(); // incorrect use

Break problems down; simplify Science tests the fewest variables Block Comments /**/ Test files Duplicate: delete without worry Test pages: use as a future reference Divide and Conquer

Remove extraneous stuff The "innocent" may only look it... Call function / methods directly try out a sub-system console; or write a little code Deconstruct function code break it but see that it acts as you expect

Postmortem Bug happened; it crashed/died etc. Dumps/Logs (not likely here) Browser Error Console might help Trace - using the info you have, you follow the steps taken to cause the problem Like a Murder Mystery

Firefox Console

Firebug Console

tracing Postmortem needs evidence Use Poor man's debugging technique OUTPUT (print or log) during exec Mental tracing would be reading the code and following it's flow 1 st attempt is ok; but will u see it?

function goofy_function(x){ alert(x); x+= 3; alert(x); if(x = 5 ){ x*10; } alert(x); }

Reconstruction Rewrite in smallest steps possible Useful for exploring APIs Useful in a console… Useful in LEARNING Could end up in another implementation; in which case chuck the buggy one.

Tool of the trade Debuggers

Run, Break, Step, Step In, Step Out Break points - mark lines in code Variable Viewer and/or Watch Call Stack Profiler Console and/or command line tools Debugger features

most popular javascript debugger Firebug Debugger

Firebug add-ons This add-on has it's own add-ons! FireRainbow adds color coding to js debugger Firebug Autocompleter adds autocomplete to console!

script

Choose.js file

Exec Controls

Rerun (reload script) Continue (run/play) Step Into function Step (aka "step over") Step Out of function

Position Displays In Code Example steps three times "Step Over" Clicking Continue/run does not show stops on breaks

Set Break Points

Clear Break Points

All break points set Disable (checkbox) Delete (X circle on right)

FireRainbow Default install may be all BLACK Script Tab of Firebug: Colors tab on right Reset to default Randomize…

Firebug Autocompleter Automatic in Console DOM Reference! View menu: Sidebar: Firebug Autocompleter Displays last autocompleted word

Firefox Console Built-in tools rapidly evolving

Built-in Firefox

type helpShow Console HTML / CSS Inspector Javascript Debugger

Not as powerful or as mature as Firebug No add-on installations Command line tool is powerful it is NOT a javascript console Console is more compact than firebug FASTER RUNNING Inspector the is weak too; debugger ok

3D html inspector