Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Basic Class / Object Question

Status
Not open for further replies.

kjedwards

Programmer
Feb 14, 2002
12
GB
Hi

I am looking to develop my first app in VB.Net using objects and I have a really basic question!

The app I am looking at keeps information about several categories of users - Individual, Sole Trader, Partnership, Limited Company, etc.

With the exception of the Name - ie First, Last name for individual, company name for companies, etc. Records for all these users share the same requirements - address, postal code, tel no, fax no, email, etc.

My question is this. Is it a good idea to create 1 class holding all the common info (address, postal code, etc) Then have seperate classes for each user category (that basically just hold the name) which each of these classes extends the class holding the common information (address, tel no, etc)?

Or Is it better to create totally seperate classes for each category of user (each class holding name, address, tel no, etc)?

The final app will save, pull data etc from a Access db.

I am really new at VB.Net although used to develop extensively in VB 4. I have never developed anything using OOP so some help please would be gratefully received.

Many thanks

Kevin


 
I would start out with one class, call it maybe "Entity" or something like that. You could put the common info in that. Then, make other classes that inherit from "Entity," only add their new, specific attributes. If you don't know what I'm talking about, here is a sample

Code:
Public Class Entity
     Private m_Address As String
     Private m_PostalCode As String

     Public Property Address() As String
          Get
               Return m_Address
          End Get
          Set(ByVal Value As String)
               m_Address = Value
          End Set
     End Property

     'Add in property for PostalCode

End Class

Public Class Individual
Inherits Entity

     Private m_FirstName As String

     'Add FirstName Property
End Class

I hope that makes sense. By inheriting from Entity, Individual will have an Address and PostalCode property.
 
This is a judgement call. You can create a parent class like RiverGuy suggests, or you can create separate classes for your address, telephone, etc. and encapsulate them in your Individual, Sole Trader, Partnership, Limited Company classes.

You need to look at what your future needs would be with these classes, as well as the supporting classes (address, phone).

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top