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

Linking objects together

Let's say I have two classes, DNA, SocialSecurityNumber, and
Fingerprint.
There is a one-to-one-to-one relationship between the classes but no
"wired" link between them.
Suppose I want a hashtable, the key being an int that i maintain and
the value being something that holds all three aforementioned objects.
the way i've been doing this is to create a simple class (or struct)
that holds the three:

class DNASSNFPContainer
{
private DNA dna;
private SocialSecurityNumber ssn;
private FingerPrint fp;

public DNASSNFPContainer(DNA dna, SocialSecurityNumber ssn,
FingerPrint fp)
{
this.dna = dna;
this.ssn = ssn;
this.fp = fp;
}

public DNA Dna
{
get
{
return dna;
}
}

public SocialSecurityNumber Ssn
{
get
{
return ssn;
}
}

public FingerPrint Fp
{
get
{
return fp;
}
}
}
this approach feels clunky. instinct tells me that there's a more
elegant way but i can't come up with anything.

thanks in advance.
JT

Nov 20 '05 #1
1 1930
ja********@gmail.com wrote in
news:11*********************@g47g2000cwa.googlegro ups.com:
Let's say I have two classes, DNA, SocialSecurityNumber, and
Fingerprint.
There is a one-to-one-to-one relationship between the classes
but no "wired" link between them.
Suppose I want a hashtable, the key being an int that i maintain
and the value being something that holds all three
aforementioned objects. the way i've been doing this is to
create a simple class (or struct) that holds the three:

<code snipped>

this approach feels clunky. instinct tells me that there's a
more elegant way but i can't come up with anything.


James,

IMO, the most natural approach would be to put those three data
members in a Person type, along with all of the other kinds of data
that can be used to describe a person.

Otherwise, you could put them in a separate type as you have done,
but change the name to something more general, like Identifiers or
Descriptors.

--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 20 '05 #2

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

Similar topics

1
by: Bernd Geiser | last post by:
Recently I tried the following: I created two libraries lib1.a and lib2.a. Both contain the object a.o which instantiates a class from b1.o (or b2.o respectively), where b1.o and b2.o have the...
15
by: Rob Ratcliff | last post by:
I'm compiling the latest version of a CORBA ORB called MICO on a Cray X1. It makes heavy use of templates and namespaces. Up until the link step, the C++ source code compiled flawlessly. But, when...
7
by: Steven T. Hatton | last post by:
Is there anything that gives a good description of how source code is converted into a translation unit, then object code, and then linked. I'm particularly interested in understanding why putting...
20
by: Steven T. Hatton | last post by:
I just read this in the description of how C++ is supposed to be implemented: "All external object and function references are resolved. Library components are linked to satisfy external...
3
by: Stephen Gray | last post by:
Hi, What I'm trying to do is produce a number of XML documents that can be linked together. For example say I had one document called "valuations.xml" which is a lists all of the...
1
by: hmiller | last post by:
I'm sorry to populate the server with yet another question about linking multiple tables and queries, howerver I have not been able to find the right criteria. My problem. I am trying to...
1
by: Christoph Wienands | last post by:
Hello everybody, I'm a C# programmer that recently was forced to look into Managed C++. Please forgive me if I might be asking stupid questions ;-) I currently have to write a wrapper class...
0
by: huiling25 | last post by:
I have a Customer.java and a Transaction.java Transaction is when the user wants to deposit money. Customer.java includes the particulars of the user such as Name, AccountID, Balance etc. I have a...
2
by: Jim Johnson | last post by:
C++ linking works by using Linker to combine object files into single exe file. Does each .cpp file compile to a single .obj file? If the .cpp code called functions in some library (.lib) does...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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: 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...

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.