Arbitrary association of objects

  • Thread starter Thread starter Bret Pehrson
  • Start date Start date
B

Bret Pehrson

I'm working on a (non-trivial) project which includes various & numerous
objects, some in my direct source control, some not.

I'm finding the need to somehow associate one object with another, somewhat
arbitrarily. The previous implementation (in C++) used external maps that
would create a 'link' between these objects. Needless to say, this was the
source of many problems due to the maintenance requirements of the links as
objects came and went.

My preference is now to create a definition that objects (specifically classes)
can derive from which would would allow for 'associations', something like:

class Associable
{
public void Associate(string key, object o);
public void Dissociate(string key);
public object Retrieve(string key);
// Other stuff omitted
};

Now, I can create an association between objects, at will, at runtime,
whenever.

Nothing too exciting, but I've been living in a cave for the last 3 years, so I
don't know if there has been any meaningful discussion of such a paradigm, and
the benefits/caveats of such. Anyone have any insights, references, etc.?

Thanks
 
Bret,
Your Associable class looks similar to a Hashtable or Dictionary. Search
for them in MSDN and check if they fit your needs.

--------------------
Message-ID: <[email protected]>
From: Bret Pehrson <[email protected]>
X-Mailer: Mozilla 4.8 [en] (Windows NT 5.0; U)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: microsoft.public.dotnet.languages.csharp
Subject: Arbitrary association of objects
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 33
Date: Thu, 29 Jan 2004 12:57:52 -0800
NNTP-Posting-Host: 68.108.95.144
X-Complaints-To: (e-mail address removed)
X-Trace: fed1read07 1075409850 68.108.95.144 (Thu, 29 Jan 2004 15:57:30 EST)
NNTP-Posting-Date: Thu, 29 Jan 2004 15:57:30 EST
Organization: Cox Communications
Path: cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!newsfeed00.su
l.t-online.de!t-online.de!130.59.10.21.MISMATCH!irazu.switch.ch!switch.ch!ec
ngs!feeder.ecngs.de!peer02.cox.net!cox.net!p01!fed1read07.POSTED!not-for-mai
l
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:216472
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

I'm working on a (non-trivial) project which includes various & numerous
objects, some in my direct source control, some not.

I'm finding the need to somehow associate one object with another, somewhat
arbitrarily. The previous implementation (in C++) used external maps that
would create a 'link' between these objects. Needless to say, this was the
source of many problems due to the maintenance requirements of the links as
objects came and went.

My preference is now to create a definition that objects (specifically classes)
can derive from which would would allow for 'associations', something like:

class Associable
{
public void Associate(string key, object o);
public void Dissociate(string key);
public object Retrieve(string key);
// Other stuff omitted
};

Now, I can create an association between objects, at will, at runtime,
whenever.

Nothing too exciting, but I've been living in a cave for the last 3 years, so I
don't know if there has been any meaningful discussion of such a paradigm, and
the benefits/caveats of such. Anyone have any insights, references, etc.?

Thanks


Rakesh, EFT.

This posting is provided "AS IS" with no warranties, and confers no rights.
Use of included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
 
Hi Bret,

Thank you for posting in the community!

Based on my understanding, you want to associate different types of objects
together in C#

========================================
Just as Rakesh said, you should refer to the classes in System.Collections
namespace. Such as HashTable, ArrayList, etc..

Some of these classes enable you to use key-and-value pairs to store
diffrent type of objects.

Please refer to:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemcollections.asp

========================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Hi Bret,

Is your problem resolved?
If you still have any concern, please feel free to tell me, thanks.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top