OOP Inheritance



Being rather new to OOP constructs I have a question regarding inheritance.

What is the proper way to setup my classes in a Company/Employee
relationship.

I have a Company Object and a company has employees (one to many
relationship) and CompanyDeductions. The Employees have EmployeeDeductions.
Based on my limited knowledge I set my objects as follows:

Public Class Company

Private _CompanyID As String

Private _Employees As New ArrayList

Private _Deductions As New ArrayList

Public Property CompanyID() As String

Get

Return _CompanyID

End Get

Set(ByVal Value As String)

_CompanyID = Value

End Set

End Property

Public ReadOnly Property Employees() As ArrayList

Get

Return _Employees

End Get

End Property

Public Sub LoadEmployees()

' Database call to get employees

Dim oDR As SqlClient.SqlDataReader

Dim oEmployee As New employee(oDR("EmployeeID"))

_Employees.Add(oEmployee)

End Sub

Public Sub LoadCompanyDeductions()

' Database call to get employees

Dim oDR As SqlClient.SqlDataReader

Dim oCompanyDeduction As New CompanyDeduction(oDR("DeductionID"))

_Employees.Add(oCompanyDeduction)

End Sub

End Class

Public Class Employee

Inherits Company

Private _EmployeeID As String

Private _FirstName As String

Private _LastName As String

Private _Deductions As ArrayList

Public Sub New(ByVal EmployeeID As String)

_EmployeeID = EmployeeID

End Sub

Public ReadOnly Property EmployeeID() As String

Get

Return _EmployeeID

End Get

End Property

Public ReadOnly Property FirstName() As String

Get

Return _FirstName

End Get

End Property

Public ReadOnly Property LastName() As String

Get

Return _LastName

End Get

End Property

Public Sub LoadEmployeeDeductions()

' Database call to get employees

Dim oDR As SqlClient.SqlDataReader

Dim oEmployeeDeduction As New EmployeeDeduction(oDR("DeductionID"))

_Deductions.Add(oEmployeeDeduction)

End Sub

End Class

Public Class CompanyDeduction

Inherits Company

Private _DeductionID As String

Private _DeductionName As String

Public Sub New(ByVal DeductionID As String)

_DeductionID = DeductionID

End Sub

Public ReadOnly Property DeductionID() As String

Get

Return _DeductionID

End Get

End Property

Public ReadOnly Property DeductionName() As String

Get

Return _DeductionName

End Get

End Property

End Class

Public Class EmployeeDeduction

Inherits Employee

Private _DeductionID As String

Private _DeductionName As String

Public Sub New(ByVal DeductionID As String)

_DeductionID = DeductionID

End Sub

Public ReadOnly Property DeductionID() As String

Get

Return _DeductionID

End Get

End Property

Public ReadOnly Property DeductionName() As String

Get

Return _DeductionName

End Get

End Property

End Class



Is this a good strategy? Or how could I make it better 9or more industry
standard?



Thank you for your time.

Ron


.



Relevant Pages

  • Re: OOP Inheritance
    ... I have a Company Object and a company has employees (one to many ... Public Property CompanyIDAs String ... Public ReadOnly Property Employees() As ArrayList ... Public Sub New(ByVal DeductionID As String) ...
    (microsoft.public.dotnet.languages.vb)
  • Re: OOP Inheritance
    ... I have a Company Object and a company has employees (one to many ... Public Property CompanyIDAs String ... Public ReadOnly Property Employees() As ArrayList ... Public Sub New(ByVal DeductionID As String) ...
    (microsoft.public.dotnet.languages.vb)
  • Re: OOP Inheritance
    ... I have a Company Object and a company has employees (one to many ... Public Property CompanyIDAs String ... Public ReadOnly Property Employees() As ArrayList ... Public Sub New(ByVal DeductionID As String) ...
    (microsoft.public.dotnet.languages.vb)
  • RE: OOP Inheritance
    ... The Employees have EmployeeDeductions. ... Public Property CompanyIDAs String ... Public ReadOnly Property Employees() As ArrayList ... Public Sub New(ByVal DeductionID As String) ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Custom Windows Authentication Principal?
    ... > Private m_RolesAs String ... > Public ReadOnly Property UserName() As String ... > Public Sub WindowsAuthentication_OnAuthenticate(ByVal sender As Object, ...
    (microsoft.public.dotnet.framework.aspnet.security)