Link Details

Link 97462 thumbnail
User 225256 avatar

By mswatcher
via geekswithblogs.net
Submitted: Jul 23 2008 / 10:36

We've all used generic classes without thinking much about it. I use List> extensively (perhaps abusively). I really only discovered the power of these classes when I started defining my own. I was looking at my code and shaking my head over the duplication between my controller classes. I finally decided to use inheritance and a template method to rid myself of this duplication. I also introduced a base interface for my view that the base controller would interact with. With a non-generic implementation, all of the subclasses would have to cast the view to the interfaces they each used. With generics, no casting is necessary. Just like List>, all of the properties and methods become strongly typed.
  • 2
  • 0
  • 102
  • 4

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Voters For This Link (2)



Voters Against This Link (0)