473,804 Members | 2,079 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Singleton Patterns, where do I put it?

Hello,

I am working on a 3teired project, data,bizlogic, userinterface.. .I have a
global class that at current is being passed around as parameters, this is,
to say the least messy...

I am reading up about singletons, but I wonder where to place it? Should I
stick it in with the userinterface.. ..how do I make it globally accessable
if its in a different layer/project...

Sorry if I sound like a noob, I am noob...
Thank you
John

Nov 20 '07 #1
4 1352
If the singleton is used for UI bits, then the UI project (web project,
winforms project) is the correct place. The example here would be
application settings for the UI.

If not, then it does not belong there. It belongs in the layer where it is
used. If it is database settings, you can guess where it goes. If neither DB
nor UI, it is probably a business object. I say probably, as you may be
using a facade pattern and have it there (not as likely).

Short answer: Need to know more about what you are placing in the singleton
to answer more concretely.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************** *************** *************** ****
| Think outside the box!
|
*************** *************** *************** ****
"John Sheppard" <sp**@nospam.co mwrote in message
news:fh******** @news2.newsguy. com...
Hello,

I am working on a 3teired project, data,bizlogic, userinterface.. .I have a
global class that at current is being passed around as parameters, this
is, to say the least messy...

I am reading up about singletons, but I wonder where to place it? Should I
stick it in with the userinterface.. ..how do I make it globally accessable
if its in a different layer/project...

Sorry if I sound like a noob, I am noob...
Thank you
John

Nov 21 '07 #2
I answered my own question...it works good!

I just put it in my Business Logic layer cause all lower layers use it...

Thanks for anyone who read my message...
"John Sheppard" <sp**@nospam.co mwrote in message
news:fh******** @news2.newsguy. com...
Hello,

I am working on a 3teired project, data,bizlogic, userinterface.. .I have a
global class that at current is being passed around as parameters, this
is, to say the least messy...

I am reading up about singletons, but I wonder where to place it? Should I
stick it in with the userinterface.. ..how do I make it globally accessable
if its in a different layer/project...

Sorry if I sound like a noob, I am noob...
Thank you
John

Nov 21 '07 #3
Thanks Cowboy...

Sorry my server was lagging at work and didnt see your response...

Im still learning about patterns, at current the singleton is the first
pattern im implementing...

At current it is a Business object so its going there...I know we have some
bad architecture issues which im working through, so its kinda half UI half
BO...but it will in the end be a BO layer...

Thanks once again, good answer, I very much appreciate it
John

"Cowboy (Gregory A. Beamer)" <No************ @comcast.netNoS pamMwrote in
message news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
If the singleton is used for UI bits, then the UI project (web project,
winforms project) is the correct place. The example here would be
application settings for the UI.

If not, then it does not belong there. It belongs in the layer where it is
used. If it is database settings, you can guess where it goes. If neither
DB nor UI, it is probably a business object. I say probably, as you may be
using a facade pattern and have it there (not as likely).

Short answer: Need to know more about what you are placing in the
singleton to answer more concretely.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************** *************** *************** ****
| Think outside the box! |
*************** *************** *************** ****
"John Sheppard" <sp**@nospam.co mwrote in message
news:fh******** @news2.newsguy. com...
>Hello,

I am working on a 3teired project, data,bizlogic, userinterface.. .I have
a global class that at current is being passed around as parameters, this
is, to say the least messy...

I am reading up about singletons, but I wonder where to place it? Should
I stick it in with the userinterface.. ..how do I make it globally
accessable if its in a different layer/project...

Sorry if I sound like a noob, I am noob...
Thank you
John

Nov 21 '07 #4
If you want a decent enough, and cheap enough, set of patterns in a "real
world" application, consider looking at dofactory.com and purchasing the
Pattern Framework. I disagree with parts of the implementation, but it is a
great learning tool. It implements nearly every pattern, somewhere, and
illustrates the use of a facade between business and UI, which is rather
nice.

My biggest issue is with the implementation of the data layer, as I feel it
is a bit too complex for a maintainable solution, but it does work as a
basic pattern.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************** *************** *************** ****
| Think outside the box!
|
*************** *************** *************** ****
"John Sheppard" <no****@spamspa m.comwrote in message
news:fi******** *@news4.newsguy .com...
Thanks Cowboy...

Sorry my server was lagging at work and didnt see your response...

Im still learning about patterns, at current the singleton is the first
pattern im implementing...

At current it is a Business object so its going there...I know we have
some bad architecture issues which im working through, so its kinda half
UI half BO...but it will in the end be a BO layer...

Thanks once again, good answer, I very much appreciate it
John

"Cowboy (Gregory A. Beamer)" <No************ @comcast.netNoS pamMwrote in
message news:%2******** ********@TK2MSF TNGP06.phx.gbl. ..
>If the singleton is used for UI bits, then the UI project (web project,
winforms project) is the correct place. The example here would be
application settings for the UI.

If not, then it does not belong there. It belongs in the layer where it
is used. If it is database settings, you can guess where it goes. If
neither DB nor UI, it is probably a business object. I say probably, as
you may be using a facade pattern and have it there (not as likely).

Short answer: Need to know more about what you are placing in the
singleton to answer more concretely.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

************** *************** *************** *****
| Think outside the box! |
************** *************** *************** *****
"John Sheppard" <sp**@nospam.co mwrote in message
news:fh******* *@news2.newsguy .com...
>>Hello,

I am working on a 3teired project, data,bizlogic, userinterface.. .I have
a global class that at current is being passed around as parameters,
this is, to say the least messy...

I am reading up about singletons, but I wonder where to place it? Should
I stick it in with the userinterface.. ..how do I make it globally
accessable if its in a different layer/project...

Sorry if I sound like a noob, I am noob...
Thank you
John


Nov 21 '07 #5

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

Similar topics

7
12481
by: Tim Clacy | last post by:
Is there such a thing as a Singleton template that actually saves programming effort? Is it possible to actually use a template to make an arbitrary class a singleton without having to: a) explicitly make the arbitrary class's constructor and destructor private b) declare the Singleton a friend of the arbitrary class
4
1801
by: Joakim Olesen | last post by:
Hi, I'm looking for a book/books about design patterns (factory patterns, singleton patterns etc). The book doesn't have to be aimed towards C# developers in particular, but the patterns should of course be useful in a ..Net/C# environment. I hope you can help me. Thanks in advance!
3
2502
by: Alicia Roberts | last post by:
Hello everyone, I have been researching the Singleton Pattern. Since the singleton pattern uses a private constructor which in turn reduces extendability, if you make the Singleton Polymorphic what sort of problems/issues should be considered? Also, I see that a singleton needs to be set up with certain data such as file name, database URL etc. What issues are involved in this, and how would you do this? If someone knows about the...
21
2472
by: Sharon | last post by:
I wish to build a framework for our developers that will include a singleton pattern. But it can not be a base class because it has a private constructor and therefore can be inherit. I thought maybe a Template can be use for that, but C# does not support Templates (will be C# generics in mid 2005). Does anyone have a solution on how the singleton pattern can be written, in C#, as a framework/ infrastructure class, so users can use this...
14
3039
by: Paul Bromley | last post by:
Forgive my ignorance on this one as I am trying to use a Singleton class. I need to use this to have one instance of my Class running and I think I understand how to do this. My question however is can a singleton class have a number of paramterised constructors enabling me to pass in parameters or not? I am trying to use the following to send in a parmeter to a constructor, but getting an error with it. I have a feeling that I am not...
9
2964
by: FluffyCat | last post by:
To add to my growing library of Design Patterns in PHP 5 I have written what I think is a good example of the Singleton Pattern. http://www.fluffycat.com/PHP-Design-Patterns/Singleton/ In the classic singleton pattern an object will distribute one and only one instance of itself. This can be useful for the sharing of resources such as a single db or network connection. A variation, sometimes called a multiton, would distribute a...
5
5381
by: tobias.sturn | last post by:
Hi! I have written this template for making a singleton: #define DECLARE_SINGLETON(classname) \ private: \ static classname* m_pThis; \ classname(); \ class Guard \ { \ public: \
3
18258
weaknessforcats
by: weaknessforcats | last post by:
Design Pattern: The Singleton Overview Use the Singleton Design Pattern when you want to have only one instance of a class. This single instance must have a single global point of access. That is, regardless of where the object is hidden, everyone needs access to it. The global point of access is the object's Instance() method. Individual users need to be prevented from creating their own instances of the Singleton.
29
1752
by: Ugo | last post by:
Hi guys, how do you make a singleton access class? Do you know a better way of this one: var singletonClass = (function( ) { // Private variable var instance = null;
0
9594
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10351
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
10096
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7638
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5534
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3834
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3002
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.