I am a little scared of Generics (as you may have noticed).
I see some value, but I also see two problems:
- Some programmers don’t/won’t get it
- Holy readability batman!
As a way to help readability, AND to allow you to make changes to your codebase easier, I think it is often wise to encapsulate your Generic types.
This is very ugly isn’t it?
Map<String, List<Account>> accounts = new HashMap<String, List<Account>>();
So encapulate:
class AccountMap extends HashMap<String, List<Account>> {
…
}
Not only is it nicer to work with in your code now, but you can add functionality to the AccountMap if it makes sense. And all of your code gets the new functionality.
September 23rd, 2004 at 11:37 pm
ah, having actually read Cedric’s blog I now see that that is what he was trying to avoid.