Skip to main content
OverflowAI is here! AI power for your Stack Overflow for Teams knowledge community. Learn more
42 votes

Why use a special "Name" class (instead of just a string) for representing object names in C++?

from everything I've seen, the Name class has no purpose besides providing a mutex, various asserts and other runtime error checking This is the reason why — it has behavior associated with it, which ...
Greg Burghardt's user avatar
17 votes

Why use a special "Name" class (instead of just a string) for representing object names in C++?

from everything I've seen, the Name class has no purpose besides [a list of various purposes] Sorry if this comes across as facetious but you rolled from claiming there's no purpose into listing the ...
Flater's user avatar
  • 51.7k
12 votes

Why use a special "Name" class (instead of just a string) for representing object names in C++?

the Name class has no purpose besides providing (...) These are good reasons to introduce a seperate class, but even if Name wouldn't have any additional behaviour it is still beneficial to have a ...
freakish's user avatar
  • 973
12 votes
Accepted

Should you manually generate UUIDs / GUIDs by modifying an existing UUID / GUID?

This very detailed answer to a similar question on stack overflow explains why GUIDs aren't random, but are highly structured, statistically unique values. By manually modifying an existing value, you ...
David Arno's user avatar
  • 39.3k
10 votes
Accepted

Protecting against malicious duplicate IDs in a distributed environment

There is no such thing as uniqueness without context. You may think your 42 is special but I can assure you other people have used 42 before. This may lead you to thinking a large UUID or a ...
candied_orange's user avatar
7 votes

Why use a special "Name" class (instead of just a string) for representing object names in C++?

@Flater correctly identified the Primitive Obsession issue, but it may be warranted to explain a bit more why primitive obsession is an issue. What's in a type? Types are used for a variety of ...
Matthieu M.'s user avatar
6 votes

High-cardinality UUID: how/where to store?

Ten years ago I would have used a integer value for the timeseries id in the database, and a separate table to map the UUID as a string (or other public id) to the internal id. Now we have UUID types ...
Pete Kirkham's user avatar
  • 1,888
6 votes

What is the minimum length for a UUID?

Behind the scenes, a UUID is just a 128-bit number. The 32 hex characters, plus four dashes, is just a friendlier version for readability. If you re-pack the 128 bits into a different format, you ...
Simon B's user avatar
  • 9,633
5 votes

What is the minimum length for a UUID?

If you're looking for interoperability, then you'll have to use the standard UUID format. If your system will be the only consumer of your ID, then you can make choices, but the choices will depend ...
Daniel Griscom's user avatar
4 votes
Accepted

Accepting the UUID collision risk based on number of clients

The whole point of UUIDs is that the risk of collisions can be safely ignored. A conflict solution is not needed. If you look at your log files and see a message "Fatal Error: UUID collision detected"...
gnasher729's user avatar
  • 45.7k
4 votes
Accepted

Is using multiple UUIDs decrease chance of collisions exponentially?

With version 4 (variant 1) random UUIDs there are 2^122 possible values. If we assume proper random* number generation that means that the chance of any two ids matching is around 1 in 5.32x10^36. ...
JimmyJames's user avatar
  • 27.4k
3 votes

Should you manually generate UUIDs / GUIDs by modifying an existing UUID / GUID?

By modifying existing UUIDs, you risk conflicting with a UUID generator provided by your system. Take the macos uuidgen command line tool mentioned above. A reasonable method that reduces the ...
gnasher729's user avatar
  • 45.7k
3 votes

Protecting against malicious duplicate IDs in a distributed environment

Fundamentally, a central registry is required for uniqueness. The system of assigning a unique prefix to different allocators, still has the centralised element of assigning the unique prefix itself ...
Steve's user avatar
  • 8,913
3 votes

Repository UUID equivalent

No, there is no unique identification for a Git repository.
Lightness Races in Orbit's user avatar
3 votes

Generate UUID in Application or Database level?

You may want to go with "both". Generating the UUIDs in the application usually makes it easier to run tests as mocking DB logic can be quite fragile. On the other side of things, if you're ...
Morgen's user avatar
  • 1,091
2 votes

Why use a special "Name" class (instead of just a string) for representing object names in C++?

Given the description, it appears the code base isn't just (merely) to enable loading/saving as XML; it appears to me that it's designed to faithfully recreate an in-memory representation of the ...
rwong's user avatar
  • 16.9k
2 votes

Why use a special "Name" class (instead of just a string) for representing object names in C++?

If you have a “Name” class instead of string, you can use it to split into family name and given name, salutation, ordering (that’s why I didn’t say “first name” because for some people the family ...
gnasher729's user avatar
  • 45.7k
2 votes
Accepted

MySQL UUID storage/presentation

As you have correctly observed, MySQL appears to lack adequate display support for UUID's like other database systems have. Many folks seem to favor storing UUID's as a 36 character TEXT field. As ...
Robert Harvey's user avatar
2 votes
Accepted

Questioning the impact of UUIDs

On the question of whether not to use UUIDs because 'You Aint Gona Need It' Given the wide acceptance of the UUID standard and the many standard library's which can generate them; UUID is usually the ...
Ewan's user avatar
  • 76.3k
2 votes
Accepted

How do I create Uuids in DDD Entities/Aggregates

I have read all about the different variants of Uuid, and I have watched talks by Martin Fowler on the topic of Event Sourcing, so I am of the thinking I should be creating Uuids that are going to be ...
VoiceOfUnreason's user avatar
1 vote

Protecting against malicious duplicate IDs in a distributed environment

You need to specify more information about the distributed service. Most systems have some central components. For example, you could shard on the ID. so when an ID comes in you takes it hash to find ...
Ewan's user avatar
  • 76.3k
1 vote

High-cardinality UUID: how/where to store?

An option may be to store the each time series as a binary blob in a common table. This can reduce the data size drastically since you only store the UUID once, and the data can often be compressed to ...
JonasH's user avatar
  • 5,489
1 vote

Better than ongoing integer and uuid as primary key

TL;DR: Depends on what you want to achieve I read a lot about using ongoing numbers vs UUID's as the primary key and had an idea how it might be possible to combine both and profit from their ...
Helena's user avatar
  • 817
1 vote

Better than ongoing integer and uuid as primary key

The main flaw is complexity. The first concern should be what you are protecting by making part of the URL random. If it's confidential or otherwise valuable information you want a whole lot of ...
l0b0's user avatar
  • 11.5k

Only top scored, non community-wiki answers of a minimum length are eligible