TGViewer
Everyday Unity Everyday Unity @everydayunity · 1.18K subscribers
Post #2426 1.22K
Which collection interface to use?

Tl;dr:
Use the most generic types possible for arguments,

Use the most specific types possible for return values

Adhere to the following guideline.

Use IEnumerable for arguments as the most generic type possible.

Use IReadOnlyList for return values as the most specific type possible.

IQueryable is a leaky abstraction because it requires you to know which LINQ expressions the ORM can understand.

IList and Array aren’t suitable because they are mutable.

Keep in mind that some implementations of IEnumerable are also leaky abstractions

https://enterprisecraftsmanship.com/posts/which-collection-interface-to-use/

#design #api
Enterprise Craftsmanship Which collection interface to use? Let’s talk about when to use which collection type and why.
  • 🔥 3
  • 👍 2
  • 👎 1
More from @everydayunity
  1. Sep 24, 2026Now you can change the effort mid session in new Claude. So the advice about caching from…
  2. Sep 24, 2026We were wondering in the comments what Claude reset does. Here is the answer https://www.r…
  3. Sep 22, 2026Introducing GPT‑6 Sol and Luna And better & cheaper sol and luna as an immediate response…
  4. Sep 22, 2026Introducing Claude Opus 5.5 \ Anthropic Cost and speed. Opus 5.5 requires less compute to…
  5. Sep 21, 2026Claude Code effort level and model selection effort means more than just "thinking time."…
  6. Sep 19, 2026Netcode for GameObjects 3.0.0 is now available It is preparation for Unity’s shared Netcod…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →