We were talking about ORM at work today and I was ...
# cfml-general
j
We were talking about ORM at work today and I was curious. I know ORM was hot several years ago but how many people are still using it? I've had mixed experiences with it and not sure I would use it again unless maybe developing a system from the ground up so I could ensure the app/database was designed with ORM in mind.
b
ORM is still rather popular in some languages like Ruby (ROR) and Grails (Groovy) but has always had mixed reception in CFML
I would say the same CF devs who loved ORM a few years ago are still using it, and the same ones who hated it then still hate it now
Ortus has a handful of apps for clients or internal that use Hibernate ORM (such as ContentBox CMS) and I've always found it to be a bit of a royal PITA (and both CF engines have historically been slow to update the underlying libs).
There are new kids on the playground however, such as
Quick
, a CFML-based ORM built on
qb
which is modeled after PHP Laravel's Eloquent library. You could try it out to see if you like it (it's modeled a lot different than Hibernate) https://quick.ortusbooks.com/
I see Sean typing and I'm waiting for him to mention ORM being the "Vietnam of programming" lol
πŸ˜‚ 3
🀣 1
s
raises hand as someone who hates all ORMs The problem is that ORMs essentially assume there's a 1:1 mapping between tables in your DB and objects in your model (with leeway for model relationships on top) -- and that often leads to either: databases with really peculiar structures (that may not even be efficient) or object models that are at least one step away from what you actually want. Databases should be viewed as "persistent storage" and you should be able to control the object model to relational model mapping yourself. Unless you are building an absolute CRUD app and your object model and relational model literally are 1:1.
I mean, I've even given conference talks on how bad ORMs can be πŸ™‚
πŸ‘ 2
d
Always hated ORM. Like knitting wearing two catcher's mitts. Never saw the plus, unless you're trying to avoid learning SQL, which isn't a universe I try very hard to think about.
j
@bdw429s does quick require coldbox? We're using FW/1
s
@Jim Priest ask in #fw1 but I'm pretty sure some folks have gotten
qb
working with FW/1... I tried to get CB modules/plugins working with FW/1 in general at one point but many of them relied too much on CB features to be easily fooled into working outside of it...
I can't remember whether I tried
qb
... I think I did (and it didn't work out of the box) but I didn't spend a lot of effort on it.
b
@elpete May know if Quick will work outside of ColdBox.
a
Unless you are building an absolute CRUD app and your object model and relational model literally are 1:1.
I think a lot of ORM usage starts this way, but the "architects" then go a bit cargo-culty and try to continue the ever-increasingly-square-like peg that is their domain model into the round hole that is ORM.
e
Quick will not work outside of ColdBox.
πŸ‘ 2
I guess you could shim an interceptor service and get it working. There might be other pieces as well.
To @Dave Merrill’s point, I’ve never viewed ORM as avoiding SQL rather giving names to bits of SQL. I talk about it in the Quick docs: https://quick.ortusbooks.com/why-quick End of the day, I don’t get paid if you do or don’t use Quick. πŸ˜… Use what makes you happy.
a
I also think a lot of ORM-driven code fails to keep the storage tier out of the way of the domain model, which is kind of its whole point. I have seen apps where all the domain object properties are name as
snake_case
to match the DB columns (!!!), which in turn meant the coding guidelines mandated all variables used snake-case. Which is a complete mishit in a
camelCase
language like CFML. Just... woolly thinking. This is not the fault of the concept of "ORM", but it's a predictable outcome of its misuse.
We're about to start a new project, and will probably use Doctrine's ORM (https://www.doctrine-project.org/projects/doctrine-orm/en/stable/index.html), but will likely restrict its usage to the repository tier. Not in the model tier. I'm undecided as yet.
s
Back in the day... there were actual object databases (like Poet, etc) and they were great because they didn't try to map objects to relations and tables -- they actually stored objects -- so your object model could be designed "properly" and they were just persistent... magically... Unfortunately, they never caught on (because you could only interact with them via the object model -- so you couldn't attach "standard" reporting tools to your database etc).
a
Nice. Except a bit of a misfire for them to not also have a SQL-oriented query API.
s
Back in the '80s, SQL wasn't as ubiquitous as it is today πŸ™‚
a
Oh right it was that long ago. I guess also back then the idea of compatibility standards between systems was less of a thing. Because "between systems" was less of a thing.
s
PostgreSQL and MySQL appeared in the mid-'90s -- OODBs had been around since the mid-'80s but died off after the mid-'90s (they were commercial databases and took a dive once solid free, open source RDBs appeared).
(I just took a trip down "memory lane" by reading the Wikipedia page https://en.wikipedia.org/wiki/Object_database πŸ™‚ )
a
Interesting history aside: the old Burroughs computing company was started by William S Burroughs' granddad!
https://en.wikipedia.org/wiki/Burroughs_Corporation (was just trying to remind myself of an old mainframe company from the 80s - not Burroughs - which is annoying me cos I can't remember)
s
ICL, perhaps?
a
It was a double-surname name. If you see what I mean. Like "Corfield Cameron" (!!!)
s
Hewlett-Packard πŸ™‚ (j/k)
a
Thank-you Sean. No. HA
s
Sperry Univac?
(to be fair, HP did make mainframes back in the day)
a
Am now wondering if it was a NZ manufacturer, and whilst there was some ubiquity in NZ, it wasn't really a thing. I was only a teen in the 80s, so had no functioning brain yet.
Dun't matter
g
I am practically a militant supporter of graph databases. and I like the "theory" of ORMs - but I see them as exactly the same as communism. A completely awesome design in theory - that just doesn't work in the real world. I find SQL is easier to understand, easier to write, easier to debug and ALWAYS faster than ORM operations. I am also a "near" militantly enthusiastic supporter of using a service layer and a gateway/DAO. These "practically" always end up being the service CFC that just calls the DAO of the same-name, with the same arguments... So I add in the use of using the onMissingMethod() in an abstract class that all DAOs extend : to skip having to write the DAO code - which is something I learnt from @markmandel while he was writing ColdSpring. At the time it blew my mind - because I never, previously, considered using "meta" - driven / dynamic programming. Which I am seriously in love with. (where it is understood without too much cognitive load).
a
I find SQL is easier to understand, easier to write, easier to debug and ALWAYS faster than ORM operations.
There is this too. It oftentimes seems like a solution looking for a problem that doesn't really exist.
πŸ‘ 2
s
You couldn't pay me to use Hibernate ever again. I find Quick to be a lot faster and much more, shall we say, hybrid? In that if I want to just do some SQL I can do that and I'm not locked into the 'THIS IS THE OBJECT RELIGION', and writing up the inevitable 'composite object' cases is really easy. So for me, Quick is just the code we write to deal with objects because we can almost always press a button and 'convert' it to QB/raw SQL.
πŸ‘ 1
z
@sknowlton everyone has their price πŸ™‚
ORM is a bit like blockchains
😜 1
b
πŸ‘ 2