473,508 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Object Visibility, whats the best way?

Hello All

I have three classes Form1, DataBase_Manager and Users.
Form 1 creates two object of type DataBase_Manager and Users as below.

Public Class Form1
Inherits Form

Public DataBase_Manager1 As New DataBase_Manager
Public User1 As New Users
My idea is that the DataBase_Manager1 object handles all database
interactions. The User1 object needs data from the database and must
ask the DataBase_Manager1 for the data.

So the user class has a function which needs to call a function in the
DataBase_Manager1 to have it retrieve the required data. How do I make
the functions in DataBase_Manager1 visible to the object User1. And
what is the best OO way of doing this in VB.NET

Many thanks for all replies.

Denis

Aug 15 '07 #1
4 1369
On Aug 15, 12:40 pm, dglees...@eircom.net wrote:
Hello All

I have three classes Form1, DataBase_Manager and Users.
Form 1 creates two object of type DataBase_Manager and Users as below.

Public Class Form1
Inherits Form

Public DataBase_Manager1 As New DataBase_Manager
Public User1 As New Users

My idea is that the DataBase_Manager1 object handles all database
interactions. The User1 object needs data from the database and must
ask the DataBase_Manager1 for the data.

So the user class has a function which needs to call a function in the
DataBase_Manager1 to have it retrieve the required data. How do I make
the functions in DataBase_Manager1 visible to the object User1. And
what is the best OO way of doing this in VB.NET

Many thanks for all replies.

Denis
If the Users class is going to consume the DataBase_Manager class, it
should have it's own instance of the class. Why not just add a
DataBase_Manager to the Users class?

Also, assuming it won't break any inheritance chains you could just
have Users inherit from DataBase_Manager giving it a copy of all it's
methods/properties.

Another option would be to make the methods in DataBase_Manager shared
(static in C#) so any class can call the methods without needing to
instantiate the class first.
Thanks,

Seth Rowe

Aug 15 '07 #2
On Wed, 15 Aug 2007 09:40:28 -0700, dg*******@eircom.net wrote:
>Hello All

I have three classes Form1, DataBase_Manager and Users.
Form 1 creates two object of type DataBase_Manager and Users as below.

Public Class Form1
Inherits Form

Public DataBase_Manager1 As New DataBase_Manager
Public User1 As New Users
My idea is that the DataBase_Manager1 object handles all database
interactions. The User1 object needs data from the database and must
ask the DataBase_Manager1 for the data.

So the user class has a function which needs to call a function in the
DataBase_Manager1 to have it retrieve the required data. How do I make
the functions in DataBase_Manager1 visible to the object User1. And
what is the best OO way of doing this in VB.NET

Many thanks for all replies.

Denis
If Database_Manager is not needed in the form except for use by Users,
put it in Users. You can do that anyway if it would work to have two
copies of Database_Manager.

If you want only one copy in the form, then you need to pass the
reference to Database_Manager to Users. You can do that with a
parameter on the Users constructor (New()) or by calling a method in
Users from the Form code after both are instantiated.
Aug 15 '07 #3
Hi Guys

Thanks for the suggestions.
I think your second suggestion is the most appropriate Jack.

Thanks

Denis

On Aug 15, 6:36 pm, Jack Jackson <jacknos...@pebbleridge.comwrote:
On Wed, 15 Aug 2007 09:40:28 -0700, dglees...@eircom.net wrote:
Hello All
I have three classes Form1, DataBase_Manager and Users.
Form 1 creates two object of type DataBase_Manager and Users as below.
Public Class Form1
Inherits Form
Public DataBase_Manager1 As New DataBase_Manager
Public User1 As New Users
My idea is that the DataBase_Manager1 object handles all database
interactions. The User1 object needs data from the database and must
ask the DataBase_Manager1 for the data.
So the user class has a function which needs to call a function in the
DataBase_Manager1 to have it retrieve the required data. How do I make
the functions in DataBase_Manager1 visible to the object User1. And
what is the best OO way of doing this in VB.NET
Many thanks for all replies.
Denis

If Database_Manager is not needed in the form except for use by Users,
put it in Users. You can do that anyway if it would work to have two
copies of Database_Manager.

If you want only one copy in the form, then you need to pass the
reference to Database_Manager to Users. You can do that with a
parameter on the Users constructor (New()) or by calling a method in
Users from the Form code after both are instantiated.- Hide quoted text -

- Show quoted text -

Aug 16 '07 #4
On Aug 16, 7:28 am, dglees...@eircom.net wrote:
Hi Guys

Thanks for the suggestions.
I think your second suggestion is the most appropriate Jack.

Thanks

Denis

On Aug 15, 6:36 pm, Jack Jackson <jacknos...@pebbleridge.comwrote:
On Wed, 15 Aug 2007 09:40:28 -0700, dglees...@eircom.net wrote:
>Hello All
>I have three classes Form1, DataBase_Manager and Users.
>Form 1 creates two object of type DataBase_Manager and Users as below.
>Public Class Form1
Inherits Form
Public DataBase_Manager1 As New DataBase_Manager
Public User1 As New Users
>My idea is that the DataBase_Manager1 object handles all database
>interactions. The User1 object needs data from the database and must
>ask the DataBase_Manager1 for the data.
>So the user class has a function which needs to call a function in the
>DataBase_Manager1 to have it retrieve the required data. How do I make
>the functions in DataBase_Manager1 visible to the object User1. And
>what is the best OO way of doing this in VB.NET
>Many thanks for all replies.
>Denis
If Database_Manager is not needed in the form except for use by Users,
put it in Users. You can do that anyway if it would work to have two
copies of Database_Manager.
If you want only one copy in the form, then you need to pass the
reference to Database_Manager to Users. You can do that with a
parameter on the Users constructor (New()) or by calling a method in
Users from the Form code after both are instantiated.- Hide quoted text -
- Show quoted text -
One other option is to make the Database_Manager implement the
Singleton pattern. That way all consumers of the class will be using
the same instance of the Database_Manager.

Thanks,

Seth Rowe

Aug 16 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3289
by: Ahmad Noori | last post by:
I have a form and in the form, I have a drop down box. Based on what the user selects, i want to display different input boxes. Here is my drop down box: <td> <select name="reptype"...
1
9519
by: Leila | last post by:
Folks I have an html file which looks like this: .. .. .. <body onLoad="WindowOnLoad();"> .. ..
4
25050
by: wasntme | last post by:
I want to toggle a <div in and out of view. My question, which of the below examples would best be supported. Or is there another approach, that would be better used..TIA.. ..A.. <a href="#"...
4
3345
by: Asterbing | last post by:
Hi. I'm trying to add an OBJECT in an existing DIV after a certain delay. Here is my currend code : <div id="dummy" style="position: absolute; visibility: visible; top: 10px; left: 10px;...
45
2958
by: bigdadro | last post by:
I've created a new class using prototype.js. After I make the ajax.request all references to this.myClassMethodorVariable are lost. Does the ajax method blow out the object persistance? I'm fairly...
7
443
by: imatts | last post by:
Hi can anyone help with this little problem. I have a simple script to swap between two divs on a page. It works perfectly in Firefox & Safari & Opera. It fails in IE 6 giving Object Required error...
4
1343
by: dgleeson3 | last post by:
Hello All I have three classes Form1, DataBase_Manager and Users. Form 1 creates two object of type DataBase_Manager and Users as below. Public Class Form1 Inherits Form Public...
1
1719
by: finizaini | last post by:
I'm receiving an "Object Expected" Error (Line:309, Char:0). I'm confused as to what is happening.Also, I can't run this code using other browser such as Fire Fox. Thispage only can view using IE....
3
8633
by: suganya | last post by:
Hi Some professionals already has developed the project using menu. In my company, they have given me task to clear the error in that. It is a script file named as "menubarAPI4.js" which is kept...
7
8082
by: sunny1009 | last post by:
Hi Guys, Can you please check this code and see whats wrong with it?? I am getting document.all.style is null or not an object error. Any help will be really appreciated. Thanks Code...
0
7225
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7326
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7498
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5627
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5053
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4707
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3194
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
418
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.