Take a look at the Decorator pattern.
http://www.dofactory.com/Patterns/PatternDecorator.aspx
Define your base 'person' class as an interface and inherit the concrete
class that implements the interface. For your 'student', 'borrower' etc
classes, inherit from the same base class and include a protected field
internally to a concrete person object. For each 'person' method in the
interface, pass the call through to the contained object. Handle other
calls yourself.
You get code reuse. You get the ability to add other methods. Yet, all
your objects derive from the same 'Person' class, you you can treat them the
same in your methods. For example, you could hold an arraylist that
contains 20 students, and 20 borrowers, and you can use the list as
containing simply 40 Person objects.
It is not perfect, but it is not bad either.
If you just can't stomach the idea of writing a bunch of methods that turn
around and call the same method on the contained class, you can split this
up. Create a Person class with basic functionality. Then create an
interface that simply defines a method that returns a Person object when a
particular method or property is called. All your other objects inherit
this interface. Their constructors would create the internal object and
each would define a method for returning the contained properties.
Your 'student' class wouldn't have access to the private and protected
members of the person class, but you would have less typing when defining
the class.
good luck,
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik
Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"John Lee" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I was trying to find an elegant way of implementing/modelling the
following
> scenario:
>
> student, borrower, reference and cosigner are all human beings - we would
> think to create a person base class and then create one class for each of
> the person type inheriting from person class - student is "IS-A" person,
....
> but there is chances that the student and the borrower will be the same
> person, how could we implement this in C#?
>
> Any suggestions and tips will be greatly appreciated!
>
> Thanks very much!
> John
>
>