473,569 Members | 2,422 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_Manage r and Users.
Form 1 creates two object of type DataBase_Manage r and Users as below.

Public Class Form1
Inherits Form

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

So the user class has a function which needs to call a function in the
DataBase_Manage r1 to have it retrieve the required data. How do I make
the functions in DataBase_Manage r1 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 1349
On Aug 15, 12:40 pm, dglees...@eirco m.net wrote:
Hello All

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

Public Class Form1
Inherits Form

Public DataBase_Manage r1 As New DataBase_Manage r
Public User1 As New Users

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

So the user class has a function which needs to call a function in the
DataBase_Manage r1 to have it retrieve the required data. How do I make
the functions in DataBase_Manage r1 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_Manage r class, it
should have it's own instance of the class. Why not just add a
DataBase_Manage r to the Users class?

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

Another option would be to make the methods in DataBase_Manage r 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*******@eirco m.net wrote:
>Hello All

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

Public Class Form1
Inherits Form

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

So the user class has a function which needs to call a function in the
DataBase_Manag er1 to have it retrieve the required data. How do I make
the functions in DataBase_Manage r1 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_Manage r 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_Manage r.

If you want only one copy in the form, then you need to pass the
reference to Database_Manage r 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...@peb bleridge.comwro te:
On Wed, 15 Aug 2007 09:40:28 -0700, dglees...@eirco m.net wrote:
Hello All
I have three classes Form1, DataBase_Manage r and Users.
Form 1 creates two object of type DataBase_Manage r and Users as below.
Public Class Form1
Inherits Form
Public DataBase_Manage r1 As New DataBase_Manage r
Public User1 As New Users
My idea is that the DataBase_Manage r1 object handles all database
interactions. The User1 object needs data from the database and must
ask the DataBase_Manage r1 for the data.
So the user class has a function which needs to call a function in the
DataBase_Manage r1 to have it retrieve the required data. How do I make
the functions in DataBase_Manage r1 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_Manage r 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_Manage r.

If you want only one copy in the form, then you need to pass the
reference to Database_Manage r 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...@eirco m.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...@peb bleridge.comwro te:
On Wed, 15 Aug 2007 09:40:28 -0700, dglees...@eirco m.net wrote:
>Hello All
>I have three classes Form1, DataBase_Manage r and Users.
>Form 1 creates two object of type DataBase_Manage r and Users as below.
>Public Class Form1
Inherits Form
Public DataBase_Manage r1 As New DataBase_Manage r
Public User1 As New Users
>My idea is that the DataBase_Manage r1 object handles all database
>interactions . The User1 object needs data from the database and must
>ask the DataBase_Manage r1 for the data.
>So the user class has a function which needs to call a function in the
>DataBase_Manag er1 to have it retrieve the required data. How do I make
>the functions in DataBase_Manage r1 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_Manage r 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_Manage r.
If you want only one copy in the form, then you need to pass the
reference to Database_Manage r 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_Manage r implement the
Singleton pattern. That way all consumers of the class will be using
the same instance of the Database_Manage r.

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
3301
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" onchange="checkVersion4()"> <option value=""></option> <option value="A">A:</option> <option value="B">B:</option> <option value="C">C:</option>
1
9529
by: Leila | last post by:
Folks I have an html file which looks like this: .. .. .. <body onLoad="WindowOnLoad();"> .. ..
4
25055
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="#" onclick="C1.style.visibility='visible';">open</a> <a href="#" onclick="C1.style.visibility='hidden'">close</a> ..B.. <a href="#"...
4
3351
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; z-index: 5; cursor: default; height: auto; background: white; width: 500px; padding: 5px; overflow: hidden;> <script language="JavaScript"><!-- var...
45
2976
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 new to OOP javascript so could be (and probably am) overlooking some detail. Below is the logic of what i'm trying to do. //Javascript code var...
4
1375
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 DataBase_Manager1 As New DataBase_Manager Public User1 As New Users
1
1726
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. Is there something that I'm missing? The error is pointing to <textarea name="tairbillno" cols="25" rows="4" wrap="HARD" id="tairbillno" ...
3
8637
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 inside the folder "menu_script". The following is the code in this file. var...
7
8088
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 function toggleDiv(id,flagit) {
0
7703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7618
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7678
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5514
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3656
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
944
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.