The Artima Developer Community
Sponsored Link

Java Buzz Forum
Encapsulating Generic Types

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Encapsulating Generic Types Posted: Sep 25, 2004 2:37 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Encapsulating Generic Types
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement
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. Cedric did this very thing. 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.

Read: Encapsulating Generic Types

Topic: Another reason why Generics should have been in the VM, and not compiler sugar with Erasure Previous Topic   Next Topic Topic: What should go in the annotations for

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use