TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: API Design, id's or objects?

1 pointsby Sbnalmost 10 years ago
I&#x27;m curious, what do you guys prefer in your methods&#x2F;functions&#x2F;members, object or the object&#x27;s id, specially in context of statically typed languages (C#&#x2F;Java&#x2F;Scala)<p>Pros of object itself: 1) More typesafe calls. 2) Get once from persistence, no need to get again<p>Cons: Most of the time no need for the actual object, just id would do, so having it costs extra to get from persistence.<p>A mixture of these techniques, as far as I can see, would only have cons of both and pros of none.<p>Also, there&#x27;s a simple work around for keeping only ids and yet be typesafe- wrap ids into a &#x27;MiniClass&#x27; for each class.<p>What are your views of pros and cons of either and a mixture, lets discuss!

no comments

no comments