Java / J2EE Needs to Add Ease of Use (Redundant) Methods

By Angsuman Chakraborty, Gaea News Network
Saturday, April 15, 2006

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() ?

Discussion
April 17, 2006: 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.

April 15, 2006: 6:49 pm

Yes, most of the time.

April 15, 2006: 12:44 pm

You rely on the machine’s configured default character set when using sockets?

YOUR VIEW POINT
NAME : (REQUIRED)
MAIL : (REQUIRED)
will not be displayed
WEBSITE : (OPTIONAL)
YOUR
COMMENT :