Ernest Friedman-Hill wrote:I was reviewing some code the other day by a junior developer that simply didn't close files at all. On questioning, it turned out he figured the garbage collector would do it.
I forgive him (her?). The early docs made such a big thing about how Java collects garbage. And as a pioneer vendor of C++, I'd gotten accustomed to having destructors do exactly that.
However, I got assigned to fix a project that was, in fact, leaking resources (network connections, actually), and now I know better.
The secret of how to be miserable is to constantly expect things are going to happen the way that they are "supposed" to happen.
You can have faith, which carries the understanding that you may be disappointed. Then there's being a willfully-blind idiot, which virtually guarantees it.