First Class Collection
A first-class collection gives a collection a domain name and keeps collection rules in one place.
Rule
The wrapper should own one collection field and behavior around that collection. Extra unrelated fields usually mean it is an entity or aggregate instead.
Workflow
Find repeated collection operations, filters, totals, limits, ordering, or validation.
Name the collection as a domain concept.
Move rules into methods on the wrapper.
Keep the internal collection immutable or defensively copied.
Expose intention-revealing operations instead of raw mutation.
Checks
Good:
OrderLines.totalAmount(),Members.hasQuorum().Bad: exposing
itemsand expecting callers to remember invariants.Avoid wrapping a collection that has no domain behavior.
Reference
Read references/patterns.md for implementation patterns.
Detailed Reference
For non-trivial implementation, review, or refactoring work, read references/details.md before giving final guidance. It contains the detailed rules, examples, smells, and migration notes that do not belong in the short invocation body.
Output
Return wrapper candidates, APIs, invariants, and migration steps.