๐ WAYPOINT LESSON
Checkpoint โ The Generic Data Store
โญโญ intermediateโณ 22 min read๐ Lesson 103 of 265
Build a constrained generic store with ordering, defaults, and variance-safe surfaces.
The gate (mini-build)
A DataStore<TId, TEntity> where TEntity : Entity<TId> and
TId : IComparable<TId>:
Add(TEntity)/Get(TId)(null when missing) /Delete(TId)(bool).AllOrdered()returns entities ordered by Id โ the constraint makes the ordering possible without casts.FirstMatching(Predicate<TEntity>)returnsTEntity?(default when none).
Supporting type: public abstract class Entity<TId> { public abstract TId Id { get; } }.
The graded test drives two different entity types through one store type โ
the whole point of generic design.