TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

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

1 点作者 Sbn大约 10 年前
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!

暂无评论

暂无评论