473,795 Members | 3,428 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Looking for a pattern

Hello,

I am looking for a good pattern. I have a rather large software app
that makes use of a service manager for its many services...
configuration, colors, data lookup, units, etc. Up until now the
service manager has been a singleton and anyone who wants access to a
service just asks the singleton.

Now we have a new requirement... run multiple instances of the
software in the same application space with different configurations.
<sarcasm>shocki ng</sarcasm>

So, now I need to think about a good design pattern to help me here.
I can only come up with two awkward options:

1. Pass a service manager key to every constructor of every class that
needs access to the service manager. The class can go to a singleton
to ask for the instance of the service manager by key. This is
awkward and I don't like it.

2. Create an interface for getting a service, and have every object in
the object tree implement the interface. Pass a "parent" object
reference to the "child" and implement the interfaces so they climb
the tree all the way to the root node to get an instance of the
service manager stored in the root node. This is better, but still
awkward.

Is there a better design pattern out there to do what I need? I am
using .NET C#, though it shouldn't matter too much (unless .NET
already has a service I can leverage).

Thanks,
Brian

Oct 31 '07
13 1366
On 2007-11-01 13:20:33 -0700, "Daniel T." <da******@earth link.netsaid:
The whole point of a singleton is to "Ensure a class only has one
instance, <i>and provide a global point of access to it.</i>" (GoF pg.
127 emphasis added.) Global access, means global IMO.
I understand that "singleton" has a perhaps a very specific meaning in
the particular book in which (it seems) this whole idea of "design
patterns" was first suggested.

However, I see nothing to prevent someone from implementing a singleton
that is not accessible globally. And I would still call it a singleton.

Furthermore, in C# any singleton itself is not accessible globally; you
need to start with the namespace, and then a particular class name, at
a minimum.

I don't see the point in raising the question of whether globals can
exist in C# anyway, but assuming the question has been raised it seems
silly to insist that the singleton pattern is somehow related to the
question. You have to define "global" first before you can say whether
the singleton pattern exists if and only if globals do, and once you've
defined "global", you don't need to look at the singleton pattern to
decide whether they exist in a language or not.

Pete

Nov 2 '07 #11
On Thu, 01 Nov 2007 01:45:54 -0000, Bilz <Br**********@g mail.com>
wrote, quoted or indirectly quoted someone who said :
>Ok, that is fine... but how does all of the classes get the key? Do
you pass them in to every constructor, and keep track of the key all
the way down the object graph?
you pass your parameters to the factory. It composes the key to see if
it built a suitable config object before, if not it calls the
constructor with the parms and adds it to the pool.

Imagine how you might cache Font bitmaps using family, size, style as
the key.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com
Nov 2 '07 #12
Peter Duniho wrote:
On 2007-11-01 13:20:33 -0700, "Daniel T." <da******@earth link.netsaid:
>The whole point of a singleton is to "Ensure a class only has one
instance, <i>and provide a global point of access to it.</i>" (GoF pg.
127 emphasis added.) Global access, means global IMO.

I understand that "singleton" has a perhaps a very specific meaning in
the particular book in which (it seems) this whole idea of "design
patterns" was first suggested.
They defined it and gave it the name.

It is a well known source.

It would be pure obfuscation to use the same well known term about
something different.
Furthermore, in C# any singleton itself is not accessible globally; you
need to start with the namespace, and then a particular class name, at a
minimum.
That has nothing to do with accessibility.

Arne
Nov 2 '07 #13
On Wed, 31 Oct 2007 19:30:23 -0000, Bilz <Br**********@g mail.com>
wrote:
>Hello,

I am looking for a good pattern. I have a rather large software app
that makes use of a service manager for its many services...
configuratio n, colors, data lookup, units, etc. Up until now the
service manager has been a singleton and anyone who wants access to a
service just asks the singleton.

Now we have a new requirement... run multiple instances of the
software in the same application space with different configurations.
<sarcasm>shock ing</sarcasm>

So, now I need to think about a good design pattern to help me here.
I can only come up with two awkward options:

1. Pass a service manager key to every constructor of every class that
needs access to the service manager. The class can go to a singleton
to ask for the instance of the service manager by key. This is
awkward and I don't like it.

2. Create an interface for getting a service, and have every object in
the object tree implement the interface. Pass a "parent" object
reference to the "child" and implement the interfaces so they climb
the tree all the way to the root node to get an instance of the
service manager stored in the root node. This is better, but still
awkward.

Is there a better design pattern out there to do what I need? I am
using .NET C#, though it shouldn't matter too much (unless .NET
already has a service I can leverage).

Thanks,
Brian

Sounds like you just need to implement versioning in a WCF
application.
----------------
AndyW,
Mercenary Software Developer
Nov 15 '07 #14

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

Similar topics

4
1985
by: Fabian | last post by:
Hi all there, I have already tried asking for help a couple of days ago. I try to rephrase better my problem: I need to grab a webpage that looks like this: <td width=80 align=center valign=top><a href="<link that should not be grabbed by the pattern>" id=r><img src=image.jpg width=66 height=79 alt="" border=1><br><font size=-2>Bla Bla text</font></a></td><td
4
1341
by: eric | last post by:
Greetings, I am looking for C++ implementations of a pattern similar to the following description. This pattern is a wrapper of sorts (in the general sense, not like a Decorator) for a single arithmetic value. In the base class of this pattern, instances can be multiplied, added, compared, copied, and generally treated just like any other arithmetic value EXCEPT that the value of such instances cannot be directly assigned nor...
3
1632
by: Steve | last post by:
Hi, I just know there must be some kind of well-known design pattern here, but I'll be damned if I can find it... Let me explain my situation. I have a hierarchy of classes for a GUI. All derived from class 'Primitive'. Fine so far.
4
1589
by: Jéjé | last post by:
Hi, I have a file which contain 1 pair of values by line like: Name1=Value1 = I nned to store these pair of values in a sortedlist. So the result expected for the 2 samples lines is: Key Value Name1 Value1
3
1305
by: ProvoWallis | last post by:
Hi, I'm looking for a little advice about regular expressions. I want to capture a string of text that falls between an opening squre bracket and a closing square bracket (e.g., "") but I've run into a small problem. I've been using this: '''\''' as my pattern. I was expecting this to be greedy but the funny thing is that it's not greedy enough in some situations.
13
3116
by: Alan Silver | last post by:
Hello, MSDN (amongst other places) is full of helpful advice on ways to do data access, but they all seem geared to wards enterprise applications. Maybe I'm in a minority, but I don't have those sorts of clients. Mine are all small businesses whose sites will never reach those sorts of scales. I deal with businesses whose sites get maybe a few hundred visitors per day (some not even that much) and get no more than ten orders per day....
9
1941
by: vbfoobar | last post by:
Hello I am looking for python code that takes as input a list of strings (most similar, but not necessarily, and rather short: say not longer than 50 chars) and that computes and outputs the python regular expression that matches these string values (not necessarily strictly, perhaps the code is able to determine patterns, i.e. families of strings...).
2
4191
by: Rob | last post by:
I'm looking for a mod 10 script that you know to work well. I have googled and found a few different ones but I would like a 2nd opinion. If you can please link me to a mod 10 script that you have used/implimented I would appreciate it. Ideally I would like a vbscript over javascript so we can have it implimented on an access db as well. Thanks.
0
2000
by: AMDRIT | last post by:
I am looking for better concrete examples, as I am a bit dense, on design patterns that facilitate my goals. I have been out to the code project, planet source code, and microsoft's patterns and practices site and it just isn't sinking in all that clearly to me. Currently we have code in production and it all works well, however it is not the way we want it. We know that we can implement a better design plan to improve performance,...
0
9672
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10437
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...
0
10214
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10164
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
10001
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...
0
9042
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6780
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5437
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
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.