When we pass a Db identifier of any object to the UI (Let’s say the PrimaryKey of an object in the url query string) aren’t we mixing two layers (Persistnet layer and presentation layer) basically?
A data-base identifier sounds like a persistent layer related data only to me in a way, but when we ‘have’ to pass it on UI, isn’t is a kind of BAD practice, where I have no idea what could be a better one though.
Is it in an exceptional case?
In short, how does the multi-tier architecture addresses this practice, passing a persistent layer data to UI?
It’s a kind of a Leaky Abstraction everybody has to deal with.
There is more examples of persistance leaking to other layers as for example validating string lenght in domain layer because the lenght in the database column is set to some value. Another example could be exposing EF IQueryable from DAL to domain layer, because doing that the potenital database scheme is leaking to the domain layer.
So I think there is a acceptable compromise we could deal with and we can’t eliminate leaky abstraction at all but we should work hard to have it at minimum. Exposing the ID to UI is a such acceptable compromise I deal with because it’s simple and everybody understand it.
But if someone has a silver bullet I will be glad to hear about 🙂