|
|
|
|
|
by PH95VuimJjqBqy
870 days ago
|
|
> If you're using an ORM, the ORM is the abstraction layer which should be sprinkled throughout the code. You shouldn't wrap a layer in a layer. preventing people with this belief from sprinkling ORM code all throughout the codebase is reason enough to ban the use of an ORM. The specifics of how you retrieve data is an implementation detail. If someone wants to use an ORM have at it, but don't sprinkle it throughout the codebase, place it behind well defined functionality (behind a system dedicated to pulling data). The fact that ORM's have their own query language should be all you need to know. One could easily argue that you should be able to manually interact with db readers all throughout the codebase, after all, it's an abstraction. But no one would ever actually argue that. Like such forward-only db readers, ORM's are a way to pull data, they are not the abstraction layer for pulling data for your application. |
|
Correct.
> (behind a system dedicated to pulling data).
That's the textbook definition of a good ORM.
> One could easily argue that you should be able to manually interact with db readers all throughout the codebase, after all, it's an abstraction.
It depends on the abstraction they present. SQL throughout the code would be a train wreck. On the other hand, something like:
* A stored procedure to have a filtered list of gizmos...
* Mapped onto an AJAX or a function call in a data layer...
* Being called whenever one needs a filtered list....
is the way to do it. If all you have are tables of simple data, that's exactly what a good ORM would do.