This is a story about an app I wrote a couple of months ago. A killer app! Yes, sir. Read on:
At some moment, the app needs to create a bunch of related temporary files. They are created in the TEMP directory using a GUID as the files base name. Each file uses the same GUID and has its own extension. When the operation is over, the app deletes the files (
.*)
The GUID trick is a nice one to generate a unique file name but it's not debugger-friendly: Good luck to find a file named after a random GUID in order to check its contents! So I added a secret registry value that allows to override the file name with a given (constnat) name instead of a random GUID. Cool!
Er... No, not cool!
Earlier this morning, I was modifiying the app. The modification involved the contents of the temp files. In order to check the result, I used this hidden registry feature to give the files a name in the source directory.
Pretty soon after the first test, I noticed that some source files had disappeared! WTF!? Oh no... I gave the temp file the same name as some 6 source files which I had just spent one hour modifying.
Result of the test: The del .* part works great :-( Even better than expected since it was coded as 'del*.*' (Note the (first) extra *. Great value to delete even more source files!).
Boy! I invented a program that deletes its own source code...
Yes, I have back-ups and yes, I have Source Control. So the disaster was pretty limited, thank you. But somehow, I believe I should fix this design or I'll be bitten again some time...