Posted by distiller
on October 12, 2004 at 1:14 AM PDT
(This was reposted from the "Welcome" topic that is now locked)
It is great that Java now has generics.
This adds to the type saftey of the language but it also creates a lot of clutter and unnecessary to particular class in your code. In fact in a lot of cases, the amount of code is not reduced by generics.
What I think would make the situation better is to have an implicit declaration feature I.e.
Rather than doing something like this:
List people = getPeople();
one would do this:
people := getPeople();
This ":=" would automatically declare a variable of type List for you. I think this is consistent with the new for/in syntax. The semantics of the operator would be that if you were to do ":=" to the same variable name within the same scope, it would be an error because you would be delcaring a variable twice.
The major advantage of this is that if you decide to refactor your code in some way and rename the class Person to PersonRole, then you just need to do a recompile, not a find and replace. Sure most IDEs have a "Refactor" facility, but this also cuts down on the amount of code you write. It also cuts down on the source level dependencies between classes.