Hacker News new | ask | show | jobs
by devmunchies 2169 days ago
Why would we have table references all over the app? We still use centralized models, just not ORMs.

Have a class representing a table and methods where you hit the database and map the response to an instance of the class.

It’s nice in a typed language when I map what the query will return and the compiler enforces it.

But not all my queries map to a class, but it’s not a big mess since we only use statically typed languages on the server so I still need to map the result to a tuple or dictionary of not a class.

2 comments

In the end, if you're writing in a non-relational language, using a relational database, and processing/using the DB responses in any way other than just returning them to the user, then you will have an ORM layer/library somewhere. Whether you should be using an off-the-shelf one or not is a different question, but you can't really escape the need to Map between your Object and Relational models (substitute Object for Datatype or Struct if you prefer).
Ah ok, so you wrote your own mapping of object relations.
yes. mapping is the trivial part. The query optimization is the more important part IMO so I like doing it manually.

I guess my problem isn't with ORM's, its with ORM SQL generation.

ORMs are just a tool, and they really don't preclude query optimisation.

All the ones I've used or written allow bypassing selects, joins or an entire query and manually translating results, so they don't have to get in the way when optimisation really matters, but the vast majority of the time IME in most apps that just isn't necessary so I'll take the reduced friction of a query builder that automates the basics as long as it allows bypassing it when required.