ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c.ze...@ads.it
Subject Re: Does iBatis use or support Generics ?
Date Tue, 13 Mar 2007 13:58:40 GMT
"Clinton Begin" <clinton.begin@gmail.com> scritti il 13/03/2007 14:42:04

> How is it safer?

Let's assume to read the interface for the our factory (object loader)

List
myFactory( ... );

List<String>
myFactory(...);


Which of the two signatures provides better information?
i.e. allows the compiler to perform stricter static type cheking?
i.e. is safer?
i.e. is more (human) readable?

Of course internally (within the factory) we have to perform one cast.
List<Strings> allows the client code use the list of looaded strings with
its correct type
without any (dangerous) casting.


> In both cases the error occurs at runtime at the exact same point in
> the code.  And at runtime both are turned into a cast anyway.
That's right.
Exactly the minimum, i.e. one and only one casting, no more.
A cast in necessary somewhere internally to the factory/loader.
Externally is much better to use a generic container along with its actual
type.
I think that we agree.

ciao
Mime
View raw message