News for hackers. Stuff that matters.

shakura

Re:Is ORM still an anti-pattern? on Wednesday June 28, 2023 @09:13AM (#36505942)
I never understood the rant on ORMs. From my point of view the main problem they solve is get rid of overinflated data access objects. In big project with complex data structure in database you can get hundreds of tables and you end up with data access objects with more than hundred methods like:

"getOrderById",

"getOrderByUser",

"getOrderByIdWithItems",

"getOrdersBySupplierWithOrderItemsAndUserAddressIAmTiredOfMakingNewNamesForMethodsPleaseKillMe"

ORMs elegantly get rid of most of these stuff and you and up with code like user.getOrders().with("item") or something like that. The downside of that is it becomes a bit harder to profile if some offender method is doing hundreds thousands queries to a database but still possible with a little bit of more work.

There are situations when you need something more complex than "SELECT ... JOIN ... WHERE ...". For example you might want to force server to use some particular index or you use subqueries or CTEs. In that case you can use native query functionality when you pass a raw SQL query to ORM and it just populates data objects with the results of a that raw SQL. Most of ORMs have such functionality. But it's very rare when it's needed, usually you have several occasions per service if it's complicated enough.

Re:RFC: Let's Disrupt Dating Apps on Monday February 24, 2020 @04:39PM (#22408737)
Badoo and Bumble are made by the same company, lol