Please do not top post.
> Sorry for me being hasty, here is the real code
> public class UsersVo implements J2EEVo
[quoted text clipped - 13 lines]
> .. add class constructor and set get methods
> }
By convention, non-constant variable (and method) names should begin with a
lower-case letter and use camel case. All-upper-case names are reserved for
static final variables used as class constants.
> public class ResultsetToVo {
>
[quoted text clipped - 8 lines]
> }
> }
The downcasts accomplish exactly nothing. The declared type of uvo will not
change, and it already knows its own runtime type.
> To answer Tom Hawtin: I am aware of instanceof, but is there another way to
> cast the uvo at run time, so that i don't have to add a new if (uvo
> insanceof someVo), every time a write a new J2EEVo that needs to use
> ResultsetToVo. Something like (just a thought):
You might need to rethink the design of fillVo(). Declaring it to take J2EEVo
arguments implies that it is only interested in the interface behaviors. The
downcasts tell us that that is a lie, the method really does care about the
implementation type (aside from the fact that you throw away the result of the
downcast in your code). You shouldn't take both points of view in the same code.
You might consider making fillVo() part of the interface, naturally without
the "uvo" argument. Each overriding class will implement fillVo() knowing full
well that the implementing type is itself. This is "polypmorphism", which is a
key concept to good (object-oriented) design.
A hint that this applies is your explicit use of the uvo argument in
fill...(), which would be the implicit "this" argument in an instance method.
Study the idea. You will end up with something similar to:
public interface J2EEVo {
public boolean isSuccess();
public void setSuccess(boolean success);
public void fill( ResultSet rs );
}
- Lew
polilop - 15 Jan 2007 10:53 GMT
> Please do not top post.
>
[quoted text clipped - 66 lines]
>
> - Lew
sorry