c# - To inherit or not to inherit? Some professional opinions wanted -


i designing c# asp.net web application uses lot of common functionality , right way deal seems through inheritence. plan make base class (person) , inherit in other classes employee , vendor, , in turn inherit employee manager, etc. way don't have define common properties such firstname, lastname, phonenumber, etc. on each 1 of them.

the second part of questions this: if use inheritence , use entity framework's codefirst entities, understand inheritence? how data stored in tables? each table have firstname , lastname column, or ef smart enough make them common table?

i hoping real object oriented programmer out there can me clear up. have gotten lot of conficting information , need actual experience on ef projects give me guidance. understanding inheritence right? if not, getting wrong? appreciated.

thanks,

bert

this not easy question, cases it's better choose composition instead of inheritance. should not derive cash dispenser calculator because calculator has display , keyboard properties. it's ridiculous.
inheritance makes sense. ask yourself, should classes have 'is a' relationship? see task, it's better make vendor , employee independent classes, both have person property. , derive manager employee.
nevertheless keep depth of inheritance little possible. deep hierarchies pain debug , understand, if there many method overrides. more inspiration topic have @ chad myers blogpost.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -