Am I on the right path part 1

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • robjens
    New Member
    • Apr 2010
    • 37

    Am I on the right path part 1

    The classes are all stored in 1 library.

    I created an abstract class Person (mustinherit) with 2 derived classes Employee and Student. This base class has all the properties a person would have. It also has several abstract methods for CRUD operations. Perhaps you would ask why I use abstract methods for this. My choice has to do with the database logic behind the code, I store data for persons in different tables, perhaps different sources lateron and this makes the code somewhat (not too much) different for every derived class.

    My first question is quite obvious but I'll ask it anyway: I assume that all my properties must always be Public Property? Or do I just use Property? I assume that both are equal. Personally I would choose for the first because it's more obvious what the access modifier for the property is but from a esthetic perspective I'd pick the latter. Second related question: I assume that in classes that are in the actual project file that uses them, we would resort to Protected Friend Property unless there is reason not to?

    Second, is using polymorphism for CRUD operations a good idea? If not, why?
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    Whoa!
    I'm answering your first question first:
    The public scope modifier indicates that something is publicly accessible. So, you can have public and private and protected properties...yo u could leave the scope modifier out but usually you know what the scope of the something is and it's best to be explicit.

    As for "Protected Friend Property"...the se properties can be used in the class they are defined (they can be also be used within any inherited class) and they can only be accessed by code in the same project/assembly.

    Maybe you should check out this MSDN article on Variable and Method Scope in Microsoft .NET.


    I'm not sure what you mean when you're asking about polymorphism.
    (wiki on polymorphism) You can use polymorphism if you want to/need to....

    Comment

    Working...