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

How to avoid repeated names?

Dear All,

Assume each objects in my code has its own name. And they cannot be the
same. Is there any good way to avoid the repeated names?

Bests,

Shuisheng

Oct 31 '06 #1
3 1244
shuisheng wrote:
Assume each objects in my code has its own name. And they cannot be
the same. Is there any good way to avoid the repeated names?
Have a name generator based on date/time/counter and use it. Your
name generator has to be a singleton.

If you're not talking of naming your run-time objects, then I am
not sure what you're talking about.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
Oct 31 '06 #2
Have a name generator based on date/time/counter and use it. Your
name generator has to be a singleton.
I wouldn't suggest time. Those computers can be really fast and time
may not guarantee unique names. Counter should work well (unless it is
something like
int name_suffix = last_name_suffix++;
with no synchronization and more than 1 thread).

Oct 31 '06 #3
"shuisheng" <sh*********@yahoo.comwrote in message
news:11**********************@b28g2000cwb.googlegr oups.com...
Dear All,

Assume each objects in my code has its own name. And they cannot be the
same. Is there any good way to avoid the repeated names?

Bests,

Shuisheng
If you really need a unique name/key consider using a GUID. This gets
generated based on a number of things ( date, time, mac address ) with no
two being the same if generated on your computer. In theory a GUID is
supposed to be unique from any other GUID anywhere, but the fact is that
although MAC addresses (your network cards identifer) are supposed to be
unique, I knew one company that reused them.

Pain in the neck, put in a nic card and not have it be able to obtain an IP
from the DHCP server, go to the server, it says that there are 2 computers
on the network with the same MAC address. Call the company, they replaced
the card with another one with a different MAC address.

Anyway, you should be able to use a GUID and your computer should even have
a generator for it that you can tie into. You'll need to look at your OS
documentation or google.
Nov 1 '06 #4

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

Similar topics

1
by: deko | last post by:
I have 3 files I need to write to - and need to make sure I have a lock on each, and take action if I can't get a lock. The code below works, but I know it could be more efficient if I used a...
7
by: mcha226 | last post by:
Hi All I have to build a page which includes a select element (as a drop down menu) with all the country names in it. However I just found out that the need to be repeated many times so the...
1
by: danfolkes | last post by:
Hey Everyone, I am trying to send repeated messages from a "Node" to a "Server". It works the first time I send the from the Node to Server, but after that it either errors, or does not do...
9
by: C#_Help_needed | last post by:
I need help with the following question. THANKS :) Write a program in c# that takes in a directory as a command line parameter, and returns the longest repeated phrase in ALL text files in that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
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...

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.