Try and experiment

When I am programming I will try things out. When I don't know if or how a feature of a programming language works, the way to find out is just trying it. The nice thing about computers and programming languages is that they won't work or will complain, when something isn't the way they expect it.

For Trying and experimenting to work, you'll need two things: feedback and reasoning skills. I could write here that you also need creativity, but I can't write anything useful about that yet.

Feedback is the way that the computer will tell you that the thing you just did, didn't work. Feedback exists in many forms: log files, error messages, CPU usage, load times, process lists, files and blank screens, all give you some information about your program. Every thing that gives some notion of the state of the working of the program, can help you find out what's going on.

Most of the time, more feedback is better. Of course with more feedback there comes more noise. Knowing where to look for certain kinds of problems will help you find your problem faster. Grepping and tailing can also help a lot when examining logfiles.

For websites there is a extension to Firefox called Firebug, which will let you inspect the HTML, Layout, CSS and DOM tree of you webpage. You can also try out if a part of your website will look better if you change margin or other parts of the CSS file without actually making the change to your websites.

Reasoning skills will help you help compare your model of the program with the actual reality of your program. Having such a model of the program in your head is the most useful thing. By trying and experimenting you will build this model. When your model is not good enough, you reasoning skills will help you find out where a problem is occuring. It is useful to add more feedback. Adding a 'print' statement before, between and after lines of code, will show which lines are executed and which aren't.

This way you can also see what the values of variables are. By comparing the values of the variables with the values that you expect, you can see where your model differs from reality.

Walking trough your code line by line is useful if you want to find out which line makes the output differ from the expected output.

Creativity will help you find new solutions or new theories for the problems you find. That's all I have to say about this.

Trying and experimenting is a safe and useful way to find problems and their solutions.

Question of the day:

Which kinds of feedback do you use while coding?

Welcome

My name is Peter Stuifzand. You're reading my personal website.

Profiles