PC Review


Reply
Thread Tools Rate Thread

Object Visibility, whats the best way?

 
 
dgleeson3@eircom.net
Guest
Posts: n/a
 
      15th Aug 2007
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

 
Reply With Quote
 
 
 
 
rowe_newsgroups
Guest
Posts: n/a
 
      15th Aug 2007
On Aug 15, 12:40 pm, (E-Mail Removed) 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

 
Reply With Quote
 
 
 
 
Jack Jackson
Guest
Posts: n/a
 
      15th Aug 2007
On Wed, 15 Aug 2007 09:40:28 -0700, http://www.pcreview.co.uk/forums/(E-Mail Removed) 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.
 
Reply With Quote
 
dgleeson3@eircom.net
Guest
Posts: n/a
 
      16th Aug 2007
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 <(E-Mail Removed)> wrote:
> On Wed, 15 Aug 2007 09:40:28 -0700, (E-Mail Removed) 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 -



 
Reply With Quote
 
rowe_newsgroups
Guest
Posts: n/a
 
      16th Aug 2007
On Aug 16, 7:28 am, (E-Mail Removed) 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 <(E-Mail Removed)> wrote:
>
> > On Wed, 15 Aug 2007 09:40:28 -0700, (E-Mail Removed) 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

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Windows 7: best firewall and best antivirus and best anti-spamsoftware is/are? RayLopez99 DIY PC 21 3rd Sep 2010 03:27 PM
Best seller,Best service,Provide Best bot cherrytree Windows Vista Games 0 29th Oct 2007 03:33 AM
Object Visibility, whats the best way? dgleeson3@eircom.net Microsoft VB .NET 4 16th Aug 2007 01:00 PM
Whats the best way to kill an object? moondaddy Microsoft Dot NET 2 28th Feb 2007 09:07 AM
"object" or "Object" whats the difference muesliflakes Microsoft C# .NET 3 5th Feb 2004 06:50 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 04:43 AM.