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.
SaveShareSend
Tags: .net, frameworks
Add your comment