473,394 Members | 1,717 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,394 software developers and data experts.

Software Design Question

is it normal to do something like:

public MYCLASS
{
private static MYCLASS defaultInstance = null;
public static MYCLASS GetDefaultInstance()
{
return MYCLASS.defaultInstance;
}
public MYCLASS(int arg1, string arg2)
{
// Init...
...
MYCLASS.defaultInstance = this;
}
}

as all other component can get a reference to MYCLASS easily
(MYCLASS.getDefaultClass())

if I don't do it this way
I need to pass a reference of MyClass to the component that will use it....

or there are better solution available in C# that is better than the above
solution?
Nov 15 '05 #1
2 1035
n!
> as all other component can get a reference to MYCLASS easily
(MYCLASS.getDefaultClass())

if I don't do it this way
I need to pass a reference of MyClass to the component that will use it....
or there are better solution available in C# that is better than the above
solution?


It looks like you're attempting a singleton object
(http://www.yoda.arachsys.com/csharp/singleton.html). If that's not what
you're after then passing in the appropriate object (or having some location
they can retrieve it from) sounds like the better plan.

n!
Nov 15 '05 #2
WHYDOYOUCODELIKETHISISNTITHARDTOREAD?
"babylon" <am***@hotmail.com> wrote in message
news:e3**************@TK2MSFTNGP09.phx.gbl...
is it normal to do something like:

public MYCLASS
{
private static MYCLASS defaultInstance = null;
public static MYCLASS GetDefaultInstance()
{
return MYCLASS.defaultInstance;
}
public MYCLASS(int arg1, string arg2)
{
// Init...
...
MYCLASS.defaultInstance = this;
}
}

as all other component can get a reference to MYCLASS easily
(MYCLASS.getDefaultClass())

if I don't do it this way
I need to pass a reference of MyClass to the component that will use it....
or there are better solution available in C# that is better than the above
solution?

Nov 15 '05 #3

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

Similar topics

24
by: Uwe Mayer | last post by:
Hi, I have the following inter-class relationships: __main__: (in file LMCMain.py) imports module FileIO defines class LMCMain instanciats main = LMCMain(...) FileIO.py:
36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
0
by: Dana Morris | last post by:
Call for Participation OMG's First Annual Software-Based Communications (SBC) Workshop: From Mobile to Agile Communications http://www.omg.org/news/meetings/SBC2004/call.htm September 13-16,...
102
by: Steve Johnson | last post by:
I'd like to hear thoughts on what books, in your opinion, are true classics in the field of software engineering. I read a lot on the topic - at least a book a month for many years. There are many...
1
by: athos | last post by:
Hi all, Believe you have sound experience in development, however, if we look at the whole Software Development Life Cycle (SDLC) of the project, say, 1. Project Initiation, 2. Gathering...
6
by: Gary James | last post by:
This may not be a direct C# question, but since I'll be using using C# for development, I thought I'd pose the question here. I'll soon be involved in the design of a new software product that...
3
by: robtyketto | last post by:
Im a student and in preparation for a testIve been given the test questions (or thereabouts, they may be asked in different words or from another perspective). I've been told that they do not...
1
by: PaulH | last post by:
Just announcing the news in the spirit of the News-groups: Artisteer - Web and Blog Design Automation Software Unveiled at BlogWorld Expo Ground-breaking Software Instantly Creates...
3
by: Ty Oft | last post by:
Hello Bytes! Maybe my question seems a bit silly (as one could simply answer it "Well, what are you more passionate about?" or stuff like that - please don't answer like this), but I am in a bit...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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...

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.