Responsible Software Design: Clean up after yourself

Responsible Software Design: Clean up after yourself

Today, for what ever reason caused it to pop into my head, I decided I should delete some temp files from my system as I try to do on a regular basis.
It turned out it has been quite a while since I had done this - more than 4 months in fact. No matter... How many temp files can accumulate in 4 months, they are "temporary" after all.

Then it hit me... I shouldn't have to do this at all... the program responsible for creating the temporary file should be disposing of it. That's how we write responsible software.

How wrong I was to assume that little fact would be held true by other developers building the software creating all of those little temp files.

Upon opening of my %TEMP%[1] folder I was shocked to find that there were over 26 thousand files taking more than 7GB of space in my profile.

[rant]
Ok, here's how it works - take note. When you create a temporary file, remove it when you're finished with it. Track it, remember you created it and get rid of it. Simple.

If it's a pseudo-temporary file, a file that you really need for longer that the program might be running for (e.g. storing workspace state), put it somewhere specific to your application (%AppData% for example) and manage the file as required.

DO NOT, leave thousands of temporary files laying around my system. For ANY reason.
[/end-rant]


  1. For those of you not familiar with environment variable shortcuts, both %TEMP% and %TMP% should map to something similar to: C:\Users\{username}\AppData\Local\Temp ↩︎