Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 135,982 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 2,247 people online right now. Registration is fast and FREE... Join Now!




Object Oriented Design

 
Reply to this topicStart new topic

Object Oriented Design

ferrous
29 Sep, 2007 - 02:38 PM
Post #1

New D.I.C Head
*

Joined: 29 Sep, 2007
Posts: 1


My Contributions
I'm making some hotel software as a project for fun. I don't have any classes this term so I thought I would practice some OOP.

I've got classes for guests and visitors and folios and amenities. This is just a start. I've read in Murach that he has a class for validation functions. These are all declared as shared so they can be used anywhere. This is a great idea, but is it object oriented since it's available to all functions?

Anyway, I'm trying to figure out where I should be opening these recordsets.

1. If I'm writing a guest to database for example, I have the code for the guest form and the code for the guest class. I'm not sure if I should open the recordset in an event sub in the form or in a member function for the class guest. The folio class has data members that are collections of the other classes. If the write to database were part of the class then a for each loop through these items in the collections would add them all to the database. Maybe I just answered my own question, but it seems like a form specific operation.

2. There are some operations that require checking the database to see if the information is already there. I'm not sure if this should be done in the form or the class. I think eventually I might be calling this function repeatedly. which can mean a lot of overhead. I want to make a function to lookup the last name or the first name so that it will automatically complete the field. Should I open the recordset once and then filter it with the current .text property of the control or should I make a form that holds a dataset of all the people that match and display it in a data grid view or something?

3. I'm having trouble getting these datasets in 2005 to fill my classes. I'm using adodb recordsets because I can make them work. I can get information for my classes if I open a data grid view and fill it with a table adapter then access the row class of the data grid view. I just haven't seen very much code for opening and accessing and filtering datasets. I tried adding a query to a table adapter, but I can't use variables like I would with a recordset. With a recordset I can make a query string and add info from local variables. When I try to add filters to datasets with the .fill function it gives me an error that some essential value was not provided. This I acheived by saying in the query "firstName = ?".

I have been successful in making the classes sit in list boxes and move around in the front end, but connection to the database is giving me a headache. Especially since it has changed in every version of visual basic since 6. I learned DAO, then ADODB, now I'm supposed to use these datasets? But they are really nice if you need to switch data providers. And I'm sure I'll see the advantages once I understand it a little better.

Thanks for any help anyone can give. If I'm not being clear just post back and I'll elaborate.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 10:51AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month