EfficientDynamoDb icon indicating copy to clipboard operation
EfficientDynamoDb copied to clipboard

Replace `TableNamePrefix` with `ITableNameFormatter` for Better Flexibility

Open icanhasjonas opened this issue 11 months ago • 0 comments

Based on the suggestion from issue https://github.com/AllocZero/EfficientDynamoDb/issues/267

Currently, the API uses a TableNamePrefix string to modify table names. This works, but is inflexible.

This PR introduces an ITableNameFormatter interface to handle table name resolution. This allows for:

  • Custom naming strategies (e.g., environment-based, hashing, localization)
  • Cleaner separation of concerns
  • Easier testing and mocking

Migration Path:

  • Mark TableNamePrefix as [Obsolete]
  • If TableNamePrefix is set, internally create a PrefixTableNameFormatter to maintain compatibility

This preserves backward compatibility while enabling greater extensibility.

Benchmark and Heap Alloc should have no- to minimal- effect. Size of passed argument (string? or ITableNameFormatter?) is the same. The formatter allows for non-heap formatting of table names (except for the simple formatter, which is more or less included for testing purposes)

icanhasjonas avatar May 11 '25 13:05 icanhasjonas