Inheritance to Interface??

  • Thread starter Thread starter Nemisis
  • Start date Start date
N

Nemisis

Hi guys,

Still getting to grips with .NET 2.0, but i am getting alot better now
then when i started out, for that thanks to everyone on here!!

I have another question. I have a SQL Table called Documents, consists
of the following fields

id
name
forcompanyid
forcontactid
forprojectid

Now a document can be against either a company, contact or project.

Should i build a base Document class, with id and name properties and
then build an extra property for each class that inherits from the base
class??

What about if i was gonna create an interface? Am i right in thinking
that i can create an interface?

Would really appreciate some views on this, and if i am missing
somethingm let me know.

Cheers
 
Inheritance should be used when there is common implementation. Interfaces
should be used when there is no common implementation, but common behavior.

So it really depends on your situation. If there is common code that you can
put in an ancestor - then you should do so, and use inheritance. Otherwise,
you end up cut and pasting the same code into all your interface
implementations - a waste.
 
Back
Top