PDA

Click to See Complete Forum and Search --> : Advices on designing the class


ocin
May 17th, 2001, 03:56 AM
I am building a database class that has the following characteristics :

1. Consist of Initial Form which will list the summary of the information. For example : in the case of Supplier Master, the Initial Form will list the Supplier Number and Supplier Name only.
On this form there are also 4 buttons : Add, Edit, Delete, Find, and Close. I used a datagrid control to show the summary information on this Initial Form (I called it like that)

2. When each of the button is clicked I will show the necessary form.
- Frm Add New if the 'Add' button is clicked
- Frm Add New if the 'Edit' button is clicked only behaving slightly differently
- Frm Find if the 'Find' button is clicked. This Frm Find will list the Supplier Name and when the user click the name then the pointer on the Initial Form will point to the correct record.

3. The reasons I create this class is because I will use this class for Data Operation (Add, Edit, Delete, Find) all over my project.


My questions are :

Do I need to create active x components ? I think for this one, I will need active x dll (in process component).

Do I just need to create a single class ?


Any advices are welcome

Thanks

hellswraith
May 19th, 2001, 04:42 PM
Why are you doing this in a class? I guess I don't fully understand what you are saying. If you build a class, you are saying you are going to create objects from it, at least that is the reason for using classes. Is there going to be more than one instance of the class at any one time? To me is sounds like you should just use a standard module to run these operations if there is only going to be one operation at a time happening.

Now, if you plan to have more users later on using these same operations and accessing the same database, then you would want to do an active x exe. This way it will run out of process and you can put the com component on a server.

Sorry if I got your question completely wrong, I didn't fully understand it.

ocin
May 21st, 2001, 04:15 AM
Thanks for the reply,

Sorry for not making myself clear.

The reasons I used class are :

1. Code reusebility. That mean : I can use this class or even this component everytime I create the database application which required input data and etc.
2. I will create an object from the class. For the time being this application is for single user and there is possibility that user want to open more than one window, ie more than one instance of the class


I am interested with your comment which said :
'Now, if you plan to have more users later on using these same operations and accessing the same database, then you would want to do an active x exe. This way it will run out of process and you can put the com component on a server.'

I did not understand what you are saying. Would you be able to exlpain to me more deeply. Secondly, when do you use class and when not to use class ?


Thanks

Crazy D
May 21st, 2001, 07:07 AM
Yes you can use 1 generic class for that. That is, you need to write code of course to retreive the database structure etc. to be able to do correct validation of any data, but yes you can. No need for an activex exe, since even if you use the dll in 10 programs at the same time, every instance of the class in the dll is unique, so no need to worry about that. As long as you also use instances of your form (like Dim m_frmAdd as New frmAdd) instead of directly calling frmAdd.

hellswraith
May 21st, 2001, 06:05 PM
What I meant was for scaleability. If you are going to have the database on it's own server, it makes sense to have one COM component that accesses that database. That way if there is a need to change the way the users need to access the database or the database itself, you only make changes to the COM component on the server instead of updating everyone's dll file on each workstation. This would be a reason to use an out of process component located on another server (DCOM).

ocin
May 21st, 2001, 10:51 PM
Thanks everyone,

I get the points