473,402 Members | 2,064 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,402 software developers and data experts.

An object to pass around

ikl
If an object of a class that is needed in many other class, should it be
passed around into each of them or just create it as a global object so that
all others can access it? Is there any other better ways?

Thanks!
Jul 22 '05 #1
6 1149

"ikl" <ik***@dsp.com> wrote in message
news:DD********************@bgtnsc05-news.ops.worldnet.att.net...
If an object of a class that is needed in many other class, should it be
passed around into each of them or just create it as a global object so that all others can access it? Is there any other better ways?


You should consider using a Singleton class.

There are many examples of code on the web, you could even search through
the archives of this group.

john
Jul 22 '05 #2

"ikl" <ik***@dsp.com> wrote in message
news:DD********************@bgtnsc05-news.ops.worldnet.att.net...
If an object of a class that is needed in many other class, should it be
passed around into each of them or just create it as a global object so that all others can access it? Is there any other better ways?


You should consider using a Singleton class.

There are many examples of code on the web, you could even search through
the archives of this group.

john
Jul 22 '05 #3

"ikl" <ik***@dsp.com> wrote in message
news:DD********************@bgtnsc05-news.ops.worldnet.att.net...
If an object of a class that is needed in many other class, should it be
passed around into each of them or just create it as a global object so that all others can access it? Is there any other better ways?


Either can work - "it depends".
Jul 22 '05 #4

"ikl" <ik***@dsp.com> wrote in message
news:DD********************@bgtnsc05-news.ops.worldnet.att.net...
If an object of a class that is needed in many other class, should it be
passed around into each of them or just create it as a global object so that all others can access it? Is there any other better ways?


Either can work - "it depends".
Jul 22 '05 #5

"ikl" <ik***@dsp.com> wrote in message
news:DD********************@bgtnsc05-news.ops.worldnet.att.net...
If an object of a class that is needed in many other class, should it be
passed around into each of them or just create it as a global object so that all others can access it? Is there any other better ways?


It's always best to pass it around as this is the most flexible and reusable
method.
Most of us are too lazy though so we just use a singleton pattern about
which there is a thread
started every few days!
Jul 22 '05 #6

"ikl" <ik***@dsp.com> wrote in message
news:DD********************@bgtnsc05-news.ops.worldnet.att.net...
If an object of a class that is needed in many other class, should it be
passed around into each of them or just create it as a global object so that all others can access it? Is there any other better ways?


It's always best to pass it around as this is the most flexible and reusable
method.
Most of us are too lazy though so we just use a singleton pattern about
which there is a thread
started every few days!
Jul 22 '05 #7

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

Similar topics

4
by: Gerhard Pretorius | last post by:
ON Win 2003 IIS6, Since yesterday, (12 Aug 2003) for some strange reason, (after installing WindowsServer2003-KB823980-x86-ENU.exe) I cannot pass the Request object to to VB COM DLL. I have...
3
by: news.rcn.com | last post by:
How can I access the request and response object for a page using javascript. I want to stick some data on with something like request.setAttribute( "User's choice for later use" ). I can't seem...
4
by: Mark Rae | last post by:
Hi, Can anyone please tell me if it's possible to pass a System.Web.Mail.MailMessage object to a ASP.NET Web Service? Maybe using XML Serialization / Deserialization? I've been asked to...
8
by: Dennis Myrén | last post by:
I have these tiny classes, implementing an interface through which their method Render ( CosWriter writer ) ; is called. Given a specific context, there are potentially a lot of such objects,...
5
by: Ray Stevens | last post by:
I have a C# dataclass object that I would like to pass to a Web Service WebMethod, modify some strings, and return it to the caller but I am getting compiler errors in the client. I'm not an expert...
2
by: Sike | last post by:
Hi everyone, I've been browsing this and a few other related newsgroups trying to get my head around this problem, and so far all the trails seem to go cold, without an acceptable solution being...
3
by: iogilvy | last post by:
i wish to have some extended functionality added to sockets i can create my own socket class class mysocket(socket.socket): and all should be fine. Except, the sockets are created for me by...
3
by: vijay.gandhi | last post by:
Hi, I am trying to convert some unmanaged code (C++) to managed code (using C++/CLI). 1) One of the functions used returns a void* which I need to cast into a handle of a managed object. Can...
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
45
by: =?Utf-8?B?QmV0aA==?= | last post by:
Hello. I'm trying to find another way to share an instance of an object with other classes. I started by passing the instance to the other class's constructor, like this: Friend Class...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
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.