A tombstone is a code marker that allows us to ensure that code we expect to be dead is, in fact, dead. By adding the tombstone, functions that are no longer referenced and visible to static analysis can indicate when they are being run dynamically. This can be disastrous if a call to a non-existing function is made.

Implementing Tombstones

A tombstone is a small function that can be used to ensure a piece of code unwanted code is truly dead.

# in pseudo-code, you'll probably want some safety, like
# a feature flag or a map to hold IDs, etc.
def tombstone(id, date)
	log.info("tombstone method called: #{id}")
end
def old_function()
	tombstone("old_function", "2023-01-01")
	# old functionality
end

Finding the Undead

This is as simple as scanning the logs for evidence of dead method activity (tombstone method called above). If you see the log, the code is actually alive. This should probably be automated.

After a given amount of time with no logs, it is much more likely that you can delete it with confidence.

See Also