OOP comes a full circle
Monday, 14 November 2005
While decomposing problems into their constituents sound like a great idea in OOP, Graham Hamilton illustrates why it is often helpful to recompose the constituents so that they fit the most common use case.
#1: Opening a Text File
In JDK 1.1 to 1.4, in order to open a simple text output file you needed to do:
FileWriter fout = new FileWriter(”fred.txt”);
BufferedWriter bout = new BufferedWriter(fout);
PrintWriter pout = new PrintWriter(bout);Say what? Why are we having to type three “new”s in order to do what should be a simple operation?
In Tiger we have finally added direct support for the common case and now you can do:
PrintWriter pout = new PrintWriter(”fred.txt”);
Did this just take 10 years? It goes to show Intelligent Design requires an Earth much much older than it actually is.