FYI: Patch: java.net: socket stuff

Mohan Embar gnustuff@thisiscool.com
Wed Nov 26 01:23:00 GMT 2003


Hi Michael,

Like I said, I am not losing any sleep over this, so you should
consider all subsequent discussion as just for fun.

>My personal rational is that it will not make the make code more clear.
>Its better in this case to throw the exception where it makes sense.
>This helps to understand the methods more easily.

>It gains nothing if we replace two very simple lines of code with a one
>liner where you probably need to look somewhere else to see what it
>really does. Even if the name for the check method is really good a
>developer dont know at hand what it really does and if there are side
>effects.

Based on your convictions, what would be your opinion of replacing
this:

  if (isClosed()) 
    throw new SocketException("socket is closed"); 

...with this:

  if (isClosed()) 
    throw new SocketException(SOCKET_CLOSED_TEXT); 

where SOCKET_CLOSED_TEXT is:

private static final String SOCKET_CLOSED_TEXT = "socket is closed";

-- Mohan
http://www.thisiscool.com/
http://www.animalsong.org/





More information about the Java-patches mailing list