DEV Community

Serguey Asael Shinder
Serguey Asael Shinder

Posted on

The Reference Number That Was Also a Rule

The order reference read
MAN-24-0418.

Branch, year, sequence.

Somebody built that on purpose
and it was a good idea,
because a customer could read it
down the phone
and you knew three things
before you opened a screen.

What nobody planned
was who would read it next.

The warehouse script took
the first three characters
to pick a printer.

A tax rule took the same three
to pick a rate.

A report grouped by them.

A partner's system validated
the shape against a pattern
and rejected anything else
before a human ever saw it.

So the format stopped being a format.

It became a rule,
enforced in six places,
none of which know
the other five exist.

Then two branches merged.

One team, one rota, one manager,
and two prefixes in the history
that both have to keep working.

Then the sequence ran past four digits
in November.

A key that meant something
ran out of meanings.

And the fix everybody reaches for
is the worst one available,
which is to keep the shape
and lie inside it.

MAN for orders that are not there.
A year that is not the year.

Now the reference is wrong
and still parses,
which is worse than wrong
and refused.

Here is the thing under it.

An identifier has one job.
It points at a row.

The moment it also carries
a branch, a date, a type, a status,
you have published a schema
inside a string,
with no migration path,
in a field that a hundred people
are allowed to read.

Keep the facts in columns.

A column can be corrected,
be null, be added to,
be given a second value
when the world gets complicated.

A prefix that somebody's
regular expression depends on
cannot.

If you want the human convenience,
have both.
A key with nothing to say,
and beside it a label
you are free to change
because nothing decides anything from it.

The test takes one question.

Ask what breaks
if that branch closes on Monday.

If any part of the answer
is a string,
the string has been doing a job
you never meant to give it.

– Serguey Asael Shinder

Top comments (0)