Java / J2EE Needs to Add Ease of Use (Redundant) Methods Java / J2EE deve aggiungere Facilità d'uso (ridondante) Metodi
Java / J2EE (Java EE) API development should now focus on adding ease of use methods to the API. Java / J2EE (Java EE) API di sviluppo dovrebbe ora concentrarsi sul aggiungendo la facilità d'uso metodi per l'API. Often such methods will be redundant. Spesso tali metodi saranno licenziati. However such redundancy is welcome as de-normalization for faster data access. Tuttavia, tale ridondanza è benvenuto come de-normalizzazione più veloce per l'accesso ai dati. Java is lagging behind PHP in ease of use. Java è in ritardo di sviluppo di PHP nella facilità di uso.
Let’s see two examples. Vediamo due esempi.
BufferedReader br = new BufferedReader(new InputStreamReader(socket.getInputStream())); BufferedReader br = new BufferedReader (nuovo InputStreamReader (socket.getInputStream ()));
Most of us who use sockets actually uses this line to be able to read lines from socket InputStream. La maggior parte di noi che utilizzano prese effettivamente utilizza questa linea per essere in grado di leggere le linee da socket InputStream. Also it uses an intermediate buffer for faster access. Inoltre essa utilizza un buffer intermedio per un accesso più rapido. I propose: Io propongo:
socket.getBufferedReader() socket.getBufferedReader ()
Similarly: Allo stesso modo:
PrintStream ps = new PrintStream(socket.getOutputStream()); PrintStream ps = new PrintStream (socket.getOutputStream ());
We need instead: Abbiamo bisogno invece:
socket.getPrintStream() socket.getPrintStream ()
This is merely the tip of the iceberg. Questo è solo la punta di un iceberg. I can point hundreds of such use cases. Posso punto di centinaia di casi tale uso. How about File.readAsString() ? Come circa File.readAsString ()?
Filed under Elencato sotto Headline News Headline News , Java Software Software Java , PHP , Tech Note Nota tech | |
| |
RSS 2.0 RSS 2,0 | |
Trackback this Article | questo articolo |
Email this Article Invia questo articolo
You may also like to read Si può anche leggere come |





April 15th, 2006 at 12:44 pm 15 aprile 2006 a 12:44 pm
You rely on the machine’s configured default character set when using sockets? Si basano sulla macchina configurato di default set di caratteri quando si usano i socket?
April 15th, 2006 at 6:49 pm 15 aprile 2006 alle 6:49 pm
Yes, most of the time. Sì, la maggior parte del tempo.
April 17th, 2006 at 3:39 am 17 aprile 2006 alle 3:39 am
Yes, but you can also extend the class and set the needed methods. Sì, ma si può anche estendere la classe e impostare la necessaria metodi. In this way you can extend Socket In questo modo è possibile estendere Socket
[code]
class MyCustomSocket extends Socket classe MyCustomSocket estende Socket
{ (
….
BufferedReade getBufferedReader() BufferedReade getBufferedReader ()
{ (
return new BufferedReader(new InputStreamReader (getInputStream())); ritorno nuovo BufferedReader (nuovo InputStreamReader (getInputStream ()));
} )
} )
[/code] [/ code]
Ok, i know is more easy ask for a extension in the standard API, but is this extension really needed? Ok, so che è più facile chiedere una proroga della norma API, ma tale estensione è davvero necessario? i’m not sure about that. Non sono sicuro che circa.