Of course, that figuring out can often be automated. As an obvious example, every standard-library container class keeps track of its own memory and frees it as needed. Nevertheless, it is hard to resist the belief that automatically freeing memory would make life a lot simpler for C++ programmers.
This approach is certainly appealing. In particular, having automated tests that capture as much as possible of a program's desired behavior is an excellent idea. But what if a program has to have a characteristic that you don't know how to test?
Sorry for the interruption.
Hello! You have been chosen to participate in
an important survey from <name deleted>, a
respected 3rd party research company.
This is for RESEARCH PURPOSES ONLY.
We are not selling anything. Your answers are grouped anonymously.
followed by "yes" and "no" buttons.
However, sometimes the division doesn't have quite the intended effect. Each individual piece of the problem might be solved correctly, but combining the solutions yields a surprise.
]]>This idea is a good one most of the time. However, sometimes there is a good and simple reason for behavior that is surprising at first glance. In such cases, following the principle of least surprise may introduce extra complexity into the system and make its behavior more surprising in the long run.
]]>Most beginners' first reaction when they make such discoveries is to think that there is something wrong with the compiler. After being disabused of that notion, they will reluctantly go looking for the problem.
However, my experience is that many programmers, especially beginners, make a critical mistake when they go on their bug hunts.
Is the third time the charm?