Webolution Designs Musings

Various posts on technology (code/programming). Our hope is that these posts improve your world.

Recent blog posts

Posted by on in Programming

Today I just would like to list off a simple debugging checklist for you to consider when working on your own programs...

  • Ensure parentheses and curly braces match up (code organization helps this)
  • Avoid typos, especially in variable/function names
  • Be consistent with the use of single and double quote usage
  • Use escape characters (\)
  • Be careful not to use '=' when you actually mean '=='
  • Be certain elements/objects have been created before attempting to use them (undefined error...applies to DOM elements in particular)
  • Do not create shadow variables...name global and local variables differently

 

The aforementioned is a simple, short list, but will go a long way in helping you avoid bugs in your code right from the start.

...
Hits: 21
Rate this blog entry:
0

Posted by on in Programming

Today I just would like to list off a simple debugging checklist for you to consider when working on your own programs...

  • Ensure parentheses and curly braces match up (code organization helps this)
  • Avoid typos, especially in variable/function names
  • Be consistent with the use of single and double quote usage
  • Use escape characters (\)
  • Be careful not to use '=' when you actually mean '=='
  • Be certain elements/objects have been created before attempting to use them (undefined error...applies to DOM elements in particular)
  • Do not create shadow variables...name global and local variables differently

 

The aforementioned is a simple, short list, but will go a long way in helping you avoid bugs in your code right from the start.

...
Hits: 19
Rate this blog entry:
0

Posted by on in Programming

Today, I want to write a short post describing the broad categories of error types...

Runtime Error

Error revealed only at runtime, such as an end user entering invalid information. Additionally, there could be issues with program incompatibility, memory issues, etc. Testing is extremely important for this error, especially if you program could be broken by an end user. Trust me...if it can be broken by an end user, they will find a way to do it.

Logic Error

Error cause by bad logic. Your code was supposed to do one thing, but it is actually built to do something else. Functioning as designed, but not as desired. This is when you go back to the drawing board. Ideally, you avoid these issues by performing your due diligence with planning lists, test plans (TDD), flowcharting and diagramming.

...
Hits: 30
Rate this blog entry:
0

Posted by on in Programming

For today's post, I wanted to cover a few more debugging techniques that I have found helpful.

Alerts

I utilize alerts throughout my code for one-off, rudimentary variable watching. I do not use it for a ton of repeated watches, because that would be just plain annoying. But it is a quick and easy way to see the value of a variable.

var myVar = "Some Value";
alert(myVar);

Comments

Anyone who knows me, knows I am big on comments. It has saved me countless hours where my memory has failed me. Another way I use comments is to prevent code from processing. Say I have a section of code that is causing problems. I may either not deal with it currently as it may be a side feature, or I may want to reveal the functionality line by line as I am debugging. Comments are an easy way to do this.

...
Hits: 49
Rate this blog entry:
0

Posted by on in Programming

Today's post is a simple one...tips for debugging. I have said it before and will say it again...Everyone's code has bugs in it. Mastering debugging techniques will give you ninja-like skills in smashing out bugs. So these are just a few tips I have incorporated into my debugging over the years...

  • Handle them one at a time. Sometimes the amount of bugs can be overwhelming. Focusing on one at a time makes the task surmountable. Additionally, sometimes fixing one bug fixes others in the same process. Over time and with practice/experience, you will learn which ones to address first in your program that will fix others.
  • Organize your code. This is critical. Messy code leads to more bugs. Think of it like your house...leaving food scattered across your counter is inviting to ants. Putting it away in containers in the fridge...no ants. Use proper indentation, comments, etc. This will allow you to see where you might be missing a curly brace or parenthesis more easily. Side note: some IDEs have ways to do this easier for you. Some do it automatically. For example, when I use Brackets, I use a plugin called Beautify that cleans up my code for me.
  • Double check your spelling. In a case sensitive language, such as JavaScript, this is even more critical. 
  • Do not forget to escape characters. Have a quote you want to output to the screen? Forget to escape it and it might become a bug.
  • Shadow variables. Be aware of the scope of your variables and when a local variable might overwrite a global variable of the same name. Better still...do not have two variables with the same name.

These are just a few tips for you. There are more, but these are the ones that in my experience have helped me out the most.

Happy Coding!

...
Hits: 41
Rate this blog entry:
0

Get in touch

Go to top