473,397 Members | 2,116 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

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 1334
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
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
by: Leila | last post by:
Folks I have an html file which looks like this: .. .. .. <body onLoad="WindowOnLoad();"> .. ..
4
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
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
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...
4
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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...
0
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
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,...
0
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...

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.