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 09:24:20 GMT


"Clinton Begin" <clinton.begin@gmail.com> scritti il 11/03/2007 04:24:15

> Well, since Java 5 generics are kind of half baked, we don't really
> need to do anything to support them.  Sure, we could make it a
> little more "warning friendly", but at the end of the day you'll be
> no more type safe....
>
> You can do this in Java 5:
>
>     List untyped = new ArrayList();
>     untyped.add(1);
>     untyped.add(2);
>     untyped.add(3);
>
>     // WOW!
>     List<String> strings = untyped;  // [*]
>
>    // Error doesn't happen until you attempt to use the array,
>    // no different than old-school casting, but less clear code.
>     for(String s : strings) {
>       ///...
>     }

Genericity is heavily based on a continuum of the static type checking that
can in no way be ensured when you retrieve objects from a non o-o database,
for sure not within the factory itself.
Sooner or later (as quoted above) the type checking has a discontinuity.
That is not a reason to disqualify genericity.
The code based on List<String> that follows [*] is safer than the
corresponding code based on List (old school).

The casting is always an act of ... faith.
Better the less than the more.
;)

ciao
Mime
View raw message