Sometimes when you're developing code, you do some action that you know requires a cleanup of some sort. Perhaps you open a file to perform an operation and know that you have to close the file when you're finished. The problem is that if the operation doesn't complete or an exception occurs during the operation, the cleanup never gets performed. The best thing to do is to perform the operation inside an ensure block to make sure that the cleanup code is always executed. This practice is especially important in an image-based development environment like Smalltalk where closing the debugger can stop the operation at any time. If cleanup code isn't performed, the resources needing cleanup can collect over time and eventually make your image unusable.
Download