"Clinton Begin" <[EMAIL PROTECTED]> 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

Reply via email to