Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Loïc Faugeron:
Short Identifier
Jun 22, 2018 @ 18:12:21

Loïc Faugeron has a post on his site covering the concept of short identifiers and covering some of the common types along with some of the downsides of the use of each.

Sometimes resources can be identified by one of their attributes (a name, title, slug) and sometimes they can't (no name, or confidential name). In the later case, an ID needs to be artificially crafted.

Two of the popular strategies is to use either an auto incremental one or a universally unique one, however when it comes to share them publicly, both strategies present some drawbacks

He lists several different types including:

  • Auto Incremental IDs
  • Short IDs
  • Hashes
  • Alphabetical representation

In the end, the method he recommends is hashing the ID value and using the first few characters (much the way you can refer to commit hashes in the Git version control tool).

tagged: short identifier list tutorial hash autoincrement shorten

Link: https://gnugat.github.io/2018/06/15/short-identifier.html


Trending Topics: