Java / J2EE Needs to Add Ease of Use (Redundant) Methods
Java / J2EE (Java EE) API development should now focus on adding ease of use methods to the API. Often such methods will be redundant. However such redundancy is welcome as de-normalization for faster data access. Java is lagging behind PHP in ease of use.
Let's see two examples.
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream()));
Most of us who use sockets actually uses this line to be able to read lines from socket InputStream. Also it uses an intermediate buffer for faster access. I propose:
socket.getBufferedReader()
Similarly:
PrintStream ps = new PrintStream(socket.getOutputStream());
We need instead:
socket.getPrintStream()
This is merely the tip of the iceberg. I can point hundreds of such use cases. How about File.readAsString() ?
Filed under Headline News, Java Software, PHP, Tech Note |
|
RSS 2.0 |
Trackback this Article
|
Email this Article
You may also like to read |




































April 15th, 2006 at 12:44 pm
You rely on the machine’s configured default character set when using sockets?
April 15th, 2006 at 6:49 pm
Yes, most of the time.
April 17th, 2006 at 3:39 am
Yes, but you can also extend the class and set the needed methods. In this way you can extend Socket
[code]
class MyCustomSocket extends Socket
{
….
BufferedReade getBufferedReader()
{
return new BufferedReader(new InputStreamReader (getInputStream()));
}
}
[/code]
Ok, i know is more easy ask for a extension in the standard API, but is this extension really needed? i’m not sure about that.