Hacker News new | ask | show | jobs
Ask HN: API Design, id's or objects?
1 points by Sbn 4039 days ago
I'm curious, what do you guys prefer in your methods/functions/members, object or the object's id, specially in context of statically typed languages (C#/Java/Scala)

Pros of object itself: 1) More typesafe calls. 2) Get once from persistence, no need to get again

Cons: Most of the time no need for the actual object, just id would do, so having it costs extra to get from persistence.

A mixture of these techniques, as far as I can see, would only have cons of both and pros of none.

Also, there's a simple work around for keeping only ids and yet be typesafe- wrap ids into a 'MiniClass' for each class.

What are your views of pros and cons of either and a mixture, lets discuss!