To light a candle is to cast a shadow.
Doors are typically closed again after being opened, windows are shut after some time, and books seldom stay open.
The same principle applies to writing robust programs: if a file is opened, or a resource allocated, this then has to be closed after being used.
It can be easy to forget the basics until they reappear within error messages, an issue that the book eloquently has a tip for:
“The finish what you start tip tells us that, ideally, the routine that allocates a resource should also free it.”
Don’t leave it to the whim of your program to deallocate files after they’ve been used: do it in the same function or class, and make sure there’s no further leaks.
Thank you for reading, see you tomorrow!
#PathToSWE