this post was submitted on 03 Dec 2025
629 points (98.9% liked)

Programmer Humor

27631 readers
1638 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] ChickenLadyLovesLife@lemmy.world 21 points 10 hours ago (8 children)

Ironically, one of the universal things I've noticed in programmers (myself included) is that newbie coders always go through a phase of thinking "why am I writing SQL? I'll write a set of classes to write the SQL for me!" resulting in a massively overcomplicated mess that is a hundred times harder to use (and maintain) than a simple SQL statement would be. The most hilarious example of this I ever saw was when I took over a young colleague's code base and found two classes named "OR.cs" and "AND.cs". All they did was take a String as a parameter, append " OR " or " AND " to it, and return it as the output. Very forward-thinking, in case the meanings of "OR" and "AND" were ever to change in future versions of SQL.

[–] jacksilver@lemmy.world 11 points 10 hours ago (6 children)

Object Relational Mapping can be helpful when dealing with larger codebases/complex databases for simply creating a more programmatic way of interacting with your data.

I can't say it is always worth it, nor does it always make things simpler, but it can help.

[–] bort@sopuli.xyz 5 points 8 hours ago* (last edited 8 hours ago) (1 children)

the problem with ORM is that some people go all in on it and ignore pure SQL completely.

In reality ORM only works well for somewhat simple queries and structures, but at some times you will have to write your own queries in SQL. But then you have some bonus complexity, that comes from 2 different things filling the same niche. It's still worth it, but there is no free cake.

[–] elkien@lemmy.today 2 points 5 hours ago

I've always seen as that as a scapehatch for one of the most typical issues with ORMs, like the the N+1 problem, but I never fully bought it as a real solution.

Mainly because in large projects this gets abused (turns out none or little of the SQL has a companion test) and one of the most oversold benefits of ORMs (the possibility of "easily" refactor the model) goes away.

Since SQL is code and should be tested like any other code, I rather ditch the whole ORM thing and go SQL from the beginning. It may be annoying for simple queries but induces better habits.

load more comments (4 replies)
load more comments (5 replies)