Multiple Inheritance scenario

D

DKode

i'm a little confused as how to accomplish this

I have multiple actors in a timesheet system I am developing. Some of
the actors are: Administrator, Manager, Reviewer, DefaultUser, etc...
Now, all users inherit from DefaultUser, but I also want an
Administrator to inherit from a Reviewer. How would you accomplish
this?c# and vb do not support multiple inheritance. I was thinking
interfaces, but I am still cloudy on interfaces or abstract classes and
when to use each method.

Any help would be appreciated. Thank you

sean
 
C

Cor Ligthert [MVP]

Dkode,

Yes Interfaces, however you can of course as well make

Actors
Defaultusers
SpecialUsers
Administrators
Reviewers

What is probably less work

Just my thought,

Cor
 
D

DKode

so if I use interfaces, I would re-coding correct? Since there is no
implementation in an interface, I would have to implement the
methods/properties in each class subscribing to the interface. This
seems like more work.

In your other example, would you use base classes? For instance:

Actors (Base Class)
DefaultUsers
SpecialUsers (Base Class)
Admins
Reviewers

is this what you meant?
 
C

Cor Ligthert [MVP]

Actors (Base Class)
DefaultUsers (inherits Actors)
SpecialUsers (inherits Actors)
Admins (inherits SpecialUsers)
Reviewers(inherits SpecialUsers)

is what I mean

:)

Cor
 
D

DKode

I think that is exactly what I was looking for. Now that I am starting
to use interfaces and abstract classes in my apps, where can I find
good information on design patterns? I have read some articles and
design patterns at the Gang of Four website, but I dont really
understand how they work or when to use them. I guess the best thing to
do would be to get a book on design patterns. On the same note, would
learning about design patterns help out my class design?

Also in this example, I was reading about a Factory Class pattern where
you can have one class inherit from multiple base classes using a
Factory based approach. Is this something that would be beneficial to
me in this example?

I appreciate the advice. thanks

Sean
 
F

Fitim Skenderi

Hi Sean,

The best book IMO on design patterns (especially for beginners) is "Design
Patterns Explained" from Allan Shalloway and James Trott. Another very good
book in design patterns is "Patterns hatching" from John Vlissides.

As per your example it depends how you will be using classes. Factory
patterns is creational pattern meaning that it is used for creating objects.

hope this helps

Fitim Skenderi
 
D

DKode

Yesterday I ordered that book from Amazon. I saw alot of people
recommending it on the newsgroups, so I figure I would buy it.

thanks for the advice.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top