How do programmers solve problems?

Everyday, programmers are faced with different problems. Were alway’s trying to figure out a way how to make our program compile or script run within the browser. And just in general. (How to build a car, how to bake a cake, how to fix your bike).

What are some ways that you figure out a problem?

I use a “input, process, output” approach. I start with the output I desire, work out what input is required and then break it down into individual processes, and apply the same model to those sub-problems.

When problems occur, the first thing I do is rethink my approach and note any assumptions I’ve made, and then test them one at a time.

There are many different approaches to take, and no matter which one you go with, it needs to be methodical. Your technique will improve over time, and you will get more and more efficient at identifying the root cause of any given problem. But as a catch-all, it is good to develop a systematic thought process so to reduce the chances of missing the problem, whether it is obvious or not.

This will also help you avoid problems in the first place.

I also talk to colleagues. They may have approached the same problem before and even if they don’t have an answer they can offer some insight most of the time.

If that fails, I Google.

My last resort is the message forum.

Cheers,
D.

break it into small pieces.

Yep, that’s pretty much it. I use the same process in web design… when something goes wrong you isolate the problem (by flushing segments of code until you spot where it’s breaking), analyse the issue (checking the code, spotting where the issue lies and working out how to fix or re-write it). The best method of debugging code is to play detective and filter through all the code that works until you get to the code which doesn’t, then deal with it as necessary. :slight_smile:

Usually I use echo (or print) function to output every single operation or query if something doesn’t work properly (so I see what is going on exactly). If that doesn’t help, code gets broken into smaller parts to see which part causes trouble. Usually it helps :slight_smile:

I use the approach of diviiding the problem into smaller parts.

“Most of your problem is solved. Don’t reinvent the wheel.” <- quoted by most of design patterns books.

Anyone used design patterns to solve their problem? :rolleyes:

I break the problem down, do a little planning, slap together a first working solution and then I’ll iterate like mad until I’m kind of happy with what I’ve got. That’s how I go about it.

I’ve used a number of design patterns before. Specifically, the MVC pattern which is incredibly popular at the moment with all of the various web development frameworks.

I grumble at a problem until it solves itself. Then I remember the answer is always 42.

^^^This. Shaking bags of rocks and sacrificing small fluffy animals also helps.

border:1px solid red;

…and…

var_dump();

…saved my marriage.

Really, when I saw that I thought…

var_dump();

You dumped your wife and the cops found you with a…

border:1px solid red;

…around your body :stuck_out_tongue:

Lol. Actually, I’d contend that var_dump(); is generally a bad thing. You should never modify the semantics of a system under test to find a bug as you don’t know if you are testing the buggered version or some new bug you just created . . . .