Fog Creek Software
Discussion Board

How many times do you solve the problem?

A previous thread brough up a thought about a developer I know.  He says for any problem he encounters in his programming, he tries to think up 3 solutions, then picks the best for his solution.  He rarely proceeds without 3 solutions to his problem.  Additionally, he's one of the best developers I've ever met.

I generally just take the first that comes to mind, and use that.  Though I do think about how efficient it is, and whether or not it will actually do what I need and well, I don't go through the formality of 3 solutions.

I was wondering how different developers solve problems.  Do you think up many solutions and choose one?  Do you just choose the first and go with it?  Is there any formal method you use for devising solutions?

Thanks for the input...

Andrew Hurst
Monday, January 27, 2003

Bizarre. A co-worker and I were just discussing this.

I find this trick very useful indeed. In my experience, if I can't come up with three solutions, then I don't understand the problem completely, or it is trivial in nature. If you think you can't come up with more than one solution, then invite a friend over to suggest a solution, and give them a buck if their idea is different than yours. You'll quickly find yourself coming up with plenty of solutions. ;-)

The real power of this technique comes through in non-trivial situations where the final solution can be pulled from the initial solutions you've thought of.  Your technique forces you to sit back from the problem and contemplate, instead of jumping in with your keyboard firing which usually leads to trouble in my humble experience.

Great idea!

D Diggler
Monday, January 27, 2003

I can certainly see the value of solving problems multiple times, and taking the best solution.

However, I'm thinking that this should be standard practice in architechture commitees, but that it should be much less useful for the individual programmer: if a problem is significant enough to not be able to be changed later, then it should unquestionably be thought about and bounced off of other programmers. If it's not that significant, I doubt it's worth the time to solve now, especially when we can profile and fix it later.

A great strategy on big things, but I'm sure on many (probably most) decisions it's overkill.

Mike Swieton
Tuesday, January 28, 2003

Its true in my case, but I don't stick to no 3. There can be n ideas. Its not the ideas that matter, if you think n instances of solving a problem it means the level of understanding of the problem ( I would say subject) is greater. This will certainly help in due course of development.

Anyway it depends upon what situation you are at. At crunching times the first one gets implmented:).

In all a very good thought.

Tuesday, January 28, 2003

I don't count the solutions I come up with. In fact, I only work 60%, which gives me lots of free time to think about the problems subconciously: Wash the dishes - oh, so THAT's the pattern I've been looking for! Cuddle the baby - WOW! those two classes actually should derive from the same interface!

and so on, and so forth.

I am a believer of The Programmers Stone: If you think about a problem long enough, eventually it will collapse.

I generally take the most asthetik solution I can come up with. So far it has paid off.

Daren Thomas
Tuesday, January 28, 2003

All of you are better programmers than I am. I try to think of as many solutions as I can. But then I part company with the rest of you. At the point of having many ideas, I find the one that I think I probably *can* do. I find that there are some solutions that I’m just not good enough to do, even though I know, if I really, really worked at it, I’d figure it out. There’s only so much time. And I have to post a billion things to the Internet! :)

Tuesday, January 28, 2003

Zen and the Art of Motorcycle Maintenance again...

There are an infinite number of solutions, some of those solutions involve changing the problem or solving it in an entirely different direction which enables the problem to be ignored.

Simon Lucy
Tuesday, January 28, 2003

I don't know about always thinking of 3 answers, or 4, or 14 before you can progress but I think its worthwhile to stop and look for more than one answer before you proceed with a problem solution, if nothing else, it serves to "audit" your first solution.

Robert Moir
Tuesday, January 28, 2003

When I have a problem, I first try to find one solution. If I find one and I "like" it (meaning, there are no negative side effects that pop to my mind at once), I proceed with it. But most times, I can only come up with solutions that solve this specific problem but have disadvantages (making the code much more complicated, making the API more difficult to use by my colleagues, performance issues, inflexibilty, you get the idea...). In this case I try to find alternative solutions and then talk to a fellow colleague in order to find the best one. This is not neccessarily because I think the fellow colleague is a superior programmer (though he might be), but because I figure that two people make a better and less biased judgement on what is the best way to do it.

Have fun,

Jutta Jordans
Tuesday, January 28, 2003

My process is similar to Jutta's. That comment about "liking" a solution sometimes isn't even based on specific things but just the general feeling that what I'm thinking of isn't the best solution. I think there's a kind of programmer's intuition that even when an idea technically works on paper you just know that there's a better or more elegant way to do it. I suppose there's always a better way to do anything, but I'm talking about knowing when you've got the best idea at the time for your particular circumstances and your development constraints (time, people, money).

Ryan Eibling
Tuesday, January 28, 2003

"When I am working on a problem I never think about beauty.  I only think about how to solve the problem.  But when I have finished, if the solution is not beautiful, I know it is wrong."

Buckminster Fuller

Tuesday, January 28, 2003

For me the best way is to start talking about it to someone else, then it all becomes so clear, though this sometimes troubles the other person!

I also had a very religious friend who would pray for guidence, and would invariably recieve answers

Daniel Shchyokin
Tuesday, January 28, 2003

Don't just think of 3 solutions, think of 3 good things about each one and three problems. If you can not think of three for every solution, you do not really understand.

Doug Withau
Tuesday, January 28, 2003

"How many times do you solve the problem?"

Exactly once. The problem no longer exists after I solved it.

I can move on to the next unsolved problem.

Tuesday, January 28, 2003

Supposedly the difference between experts and amateurs, in any area of research, is that when confronted with a problem experts ask themselves "in what ways can I solve this problem" whereas amateurs get right into work thinking "let's solve this problem". Not sure what this means though;-)

Rikard Linde
Wednesday, January 29, 2003

Rikard said... "...whereas amateurs get right into work thinking "let's solve this problem". Not sure what this means though;-)"

I think that about hits the nail on the head :)  I'm still working at becoming a better programmer.  I'm 22, been out of school (BS in CSE at UC Davis) for about 8 months now working.  I've got a lot to learn, which is why I read this boards, software development books, and pick the brain of every developer I know.

Thanks for the input everyone.

Andrew Hurst
Wednesday, January 29, 2003

*  Recent Topics

*  Fog Creek Home