Sunday, 26 November 2006 | |
Object Ownership Way back when, back deep in the primordial mists of DOS, I used to code in C++. When using C++ I spent much time asking myself deep philosophical questions, such as "is the object I am about to try and make use of still there?" Through some very hard knocks I learnt and applied these rules:
Java has no pointers*. So a lot of the problems solved by tight control of ownership are no longer present. In my Java coding I do try to adhere to my old C++ rules, but I have noticed that other Java developers don't seem to grant them the importance that I do. Or even are aware of them... So I really enjoyed Alex Potanin's presentation to the Wellington Java User Group. He shared both his ideas and a way to formally implement rules for object ownership in Java. Given my past this is real syntactic sugar that I could live with. Sadly, in the post meeting wash-up I discovered that I was in a minority. A very small minority. Further proof, I guess, that Java has changed the programming paradigm...
*I do wish that the Java "null pointer exception" could be renamed. That one line is giving us a view straight through to the underlying implementation. Wouldn't something along the lines of "unassigned object reference" be better? Or even more honest: "Developer " + @author + " - stuffed up: there has been an attempt to use an unassigned object reference!". comments? [] 9:56:37 PM |