a case for multiple inheritance
- From: John <no@xxxxxxxx>
- Date: Wed, 20 Jun 2007 20:53:34 -0700
Hi All,
Although C# has Generics, it still does not support the generic programming paradigm. Multiple inheritance is required to support real generic programming. Here is a simple design pattern to illustrate this.
Problem:
I need to expose two lists of objects from a high-level class. I would like to expose these lists as read-only, but require write access internally.
Solution:
1) Create a generic ProtectedList<T> class which inherits from List<T> and overrides the write functions (using the new modifier) to change the access level from public to protected.
2) Inherit both specialized List<T> by the high-level class
Discussion:
While this usage of inheritance does not conform to the "is-a" relation imposed by the OOP paradigm, it is a simple and easy way to reuse code in a generic way.
Thanks for any thoughts, and good solutions to this problem in the existing C# paradigm.
.
- Follow-Ups:
- Re: a case for multiple inheritance
- From: P_hil
- Re: a case for multiple inheritance
- From: cody
- Re: a case for multiple inheritance
- From: Christof Nordiek
- Re: a case for multiple inheritance
- From: Tom Spink
- Re: a case for multiple inheritance
- Prev by Date: Re: changing TextBox to enabled during runtime
- Next by Date: Re: Upload a text file thru webclient
- Previous by thread: changing TextBox to enabled during runtime
- Next by thread: Re: a case for multiple inheritance
- Index(es):
Relevant Pages
|