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.
Bizarre. A co-worker and I were just discussing this.
I can certainly see the value of solving problems multiple times, and taking the best solution.
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.
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!
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! :)
Zen and the Art of Motorcycle Maintenance again...
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.
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.
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).
"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."
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!
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.
"How many times do you solve the problem?"
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 said... "...whereas amateurs get right into work thinking "let's solve this problem". Not sure what this means though;-)"
Fog Creek Home