Debugging Tips
Compare the user’s expected results to the intended results, and decide whether it is a poorly implemented feature or a bug
Check the database and the query results to see if the data is good or bad
Limit constructor variables to things that you are going to need throughout the lifetime of the function like current status variables, not temporary things like database handles, file handles, AJAX handles, etc.
Use callbacks and closures to reduce the number of variables creating to simply collect data
Make sure that quotes are consistently single or double on both ends of a string
Make sure the test environment matches the production environment so the bug can be reproduced consistently
Ask the user to show each screen they filled out that included that module of the website up until the error
Make note of floating point calculation estimates as being approximate when rounding up or down to a particular number of significant digits
Use get the hell out of dodge error handling whenever possible
Use cftransaction style batch processing for queries that may need to be canceled and reversed
Track modifications to existing variables and replace all updates with temp variables
Make copies of existing variables to perform updates and return new values to restore the original state
Check floating point calculations by hand or desktop app for accuracy, and give precedence to charging exact dollar amounts in lieu of rounding the displayed interest or tax rate instead of showing the inifinite number string
Write down the amount of time wasted on researching bugs that are redundant or erroneous due to poorly written test plans and business cases.
Set final variable names to a string value instead of inserting test strings directly into the input
Setup unit tests and static analysis tools before development using simple examples
Use metrics to track the return on investment(ROI) on bug analysis, requirements analysis, implementation changes, and unit testing
Search queries for column names(select user_id from users) associated with invalid variable values
Search column name references(where user = ‘form.var’) for invalid form field value assignments
Search column value assignments(var = get_stuff.user_id) for missing variable initialization
Search form field names(input name=”bug” value=”$var”) for invalid local variable references
Search local variable initialization references(var bug = “) for missing assignments
Search variable references(if var == 1) for missing existence checks(if var != undefined && var == 1)
Search function calls( = myfunc.child) for missing argument references
Don’t use global variables that are not constants
Don’t pass variables without referencing their scope or namespace
Validate the initial and subsequent assignments of values to reused hashes
Split hashes of more than five keys into a group of nested hashes
Save reusable database records in JSON or XML files instead of global variables
When dynamically creating a variable and setting it’s properties in a loop or conditional statement, set the new object to a temp variable, add the property values, then reassign it to the real value to be thread safe
Blog at WordPress.com. | Theme: Pool by Borja Fernandez.
Entries and comments feeds.