do (BufferedInputStream bis = new BufferedInputStream(is); BufferedOutputStream bos = BufferedOutputStream(os)) {Which is certainly an improvement, but I just don't understand why we can't get a real destructor in Java. My nearly twenty years of OO programming have convinced me that if a language has a constructor, it should have a destructor. Exceptions are academic languages and pseudo code, both of which are free of resource concerns. Real world programming is almost always working with some sort of a finite resource, such as database connections. It is not just good form to clean these up the moment you are done with them, but often simply necessary to make things work in a busy production system.
// do stuff with bis and bos
}
These new blocks are an improvement I suppose, but they still suffer the fatal flaw of resource management in Java which is that it is dependent upon the programmer to always remember to free up resources. My real world experience has also taught me that the less that you have to have programmers do manually, the less problems you'll have. I'll gladly accept the new features of Java 7, but I'm still waiting for a truly automatic solution to resource management in Java.
No comments:
Post a Comment