Re:The Clean Coder: The Craftsman 62, The Dark Path.
by xyzzyz on Tuesday October 05, 2010 @02:57PM
(#1760939)
You are right in what you say, however I think I have been misunderstood. It is well defined what it means for an algorithm to be correct -- it means that it returns expected output for a given input. Ambiguous situations you are talking about are when the problem is not well defined. That is why I used the word "algorithm" in my first comment. Trial and error is perfectly fine when we are not exactly sure what result we expect, but we will "feel" when it's good enough. It is unacceptable if we know exactly what the result should be, though.
When the problem is well-defined, like word-wrapping, or sorting, or whatever, if you blindly stagger and write code hoping it will work, instead of stopping to think why it should work, you are doing it wrong.
In many of the more interesting fields, it's often not well-defined what it means for an algorithm to be "correct" anyway. What would a "correct" web search algorithm look like? How about a "correct" recommendation algorithm? A "correct" flight fare prediction algorithm? A "correct" stock trading algorithm? A "correct" Starcraft AI? There're "better" and "worse" algorithms for these, but there's no such thing as a "correct" one.
For many problems that do have an obvious "correct" solution (eg. OCR, face recognition, fare optimization), getting there is a nearly intractable problem, and the interesting part is in figuring out how you can approximate it as well as possible with the resources you have available is the best you can do.