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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

OOP

Status
Not open for further replies.

xloop

Programmer
Nov 12, 2001
86
GB
Hi

I have a very general question about Object Orientated programming.

I totally understand objects but i occassionally struggle to understand how some situations fit in to the whole OO thing.

Let me explain.

If i have a customers table with CustomerID, Name, Age

There are two things i could do.

I could create a Customer Class that had properties of each column in the table, then when i need to update the table i could call methods on the class.

OR

I could bind the data directly from the db and update the table via a dataset. Although this does involve OO i don't actually use any of my own classes.



I'm basically building a business tool which involves managing clients, projects, jobs and tasks. Now, i can't help but think that this just doesn't need to be done 'very OO'. I can see myself being able to create a few classes with a bunch of static methods and everything will work hunky dory, BUT, i want to be able to get into the OO habit.

Can anyone suggest anything?

Thanks
 
Well, I think you could have your dataSets, connections and commands in your customer class. You could still have a dataSet in your user class, but have it be a mirror image of the one if your Customer class. And bind controls to the dataSet in your user class. And use the Update method of your customer class in conjunction with your new, modified dataSet from your user class.
 
There's a third option. I haven't tried it, but if you were to write a class that implemented IListSource, ISupportInitialize, & the ISerializable interfaces, it could be used in place of System.Data.DataSet

That way, your own class could act as a data source for your bound controls. That would act as your "business object layer", and it could talk to your "data object layer", which does the actual DB access.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top