12 ms·
Problems with Object/Relational Mapping (2006)
- neilk 9y agoIt's a good description of the problems of ORM and their possible resolutions. Personally, I prefer to interact with a relational database via a good query builder. The advantage of a query builder is that you inevitably end up with dozens of slightly different queries. With a query builder you can make a query just like another, but with slightly different constraints or joins or whatever you like. You can then populate objects with said queries when it make sense, and do other non-objecty operations like reporting and search. The entire point of an object system is to reduce coupling, so IDK why people are so eager to tightly couple their programming model to storage. But about the Vietnam part... really, that's a shocking analogy. The overlong, painfully US-centric military history part could be completely excised. I didn't even understand the title at first. Vietnam is not solely defined by America's failed attempt to ~~napalm it into submission~~ nobly preserve democracy.
- hyperpallium 9y agoThe entire point of relational algebra was also to reduce coupling... let's couple them! Though to be fair, I suspect the relational approach became popular more because it was easier/faster than because it was flexible. ORM popularity then makes sense.
- le-mark 9y agoI agree that the Vietnam war exposition was very odd and out of place for a technical article. Gavin King (creator of hibernate/nhibernate) has always said ORM's are just a tool in a box and encouraged people to use what's appropriate[1]. I often see project teams adopting an ORM and attempting to shoehorn all database access into the ORM framework they've adopted. Needless to say, these teams grow to hate their ORM, with good reason. The way this manifests in applications is often times a frontend client making several calls to the ORM backend for lists of objects, then mixing, matching, swizzling the data to what needs to be displayed to the user when a single call to a well crafted query would save bandwidth, improve application responsiveness, and be easier to debug and maintain. It is relatively easy to draw a clear line between using ORMs for domain model persistence (complex, stateful CRUD) and SQL for relational model interaction (complex, stateless querying). It really comes down to: don't use ORMs for querying and don't use SQL for complex CRUD [1] https://www.reddit.com/r/programming/comments/2cnw8x/what_orms_have_taught_me_just_learn_sql/cjheyec/ https://www.reddit.com/r/programming/comments/2cnw8x/what_or...
- arwhatever 9y agoConvincing a team to choose the best approach based on the situation is the hardest thing to do in the universe. It's got to be an all-or-nothing decision! 99.9% of the teams in the world are out there right now, either cranking out reams of unnecessarily boilerplate CRUD, or else torturing their application and database performance trying to get their ORM to accomplish things for which it is not at all suited.
- WalterGR 9y agoCitations needed.
- arwhatever 9y agoHave worked on 9 teams in the past 5 1/2 years or so, and 0 of them had the wherewithal to choose the optimal data access strategy on a situational basis. So, 100%, not 99.9% :-)
- igkgudtzucf 9y agoI was dating a Vietnamese woman a little while ago. This eventually, inevitably came up. It is extremely difficult to defend a US policy that measures "success" as a body count metric. The Vietnamese people vividly remember this, I don't think it's appropriate to make flip comparisons to a humanitarian catastrophe perpetrated by people the likes of Henry Kissinger in multiple countries, with body counts of millions.
- deleted 9y ago[deleted]
- sgt101 9y agoOne two year spell with Hibernate was the end of all flirtations with ORM at our gaff. "No transparent persistence shall be the sum of transparent persistence."
- fizixer 9y agoORM is the Vietnam of Computer Science, because OOP is the Vietnam of Computer Science: A 25-year failed experiment in boosting productivity of masses of mediocre programmers using this one true silver bullet.
- booleandilemma 9y agoHi, mediocre programmer here. OOP is the most popular paradigm because it works the best for the greatest number of people and projects. It's natural to break large systems into component parts recursively, and to let components have their own state. What alternative did you have in mind? Functional programming?
- TeMPOraL 9y agoBreaking up a problem recursively into stateful components is completely orthogonal to OOP.
- thesmallestcat 9y agoAs is coupling state and function. Parent's comment is a good demonstration of the inertia of misinformed adherence to OOP.
- halter73 9y agoSince you seem confident that your understanding of OOP is better than that of "misinformed" people like me who don't think that coupling state and function is completely orthoganal OOP, can you explain what isn't completely orthoganal? A succinct definition of OOP would be nice to combat the misinformation you're complaining about. The description of OOP provided in the Wikipedia article on programming paradigms [1] matches my current understanding of OOP. > object-oriented which groups code together with the state the code modifies, Maybe that's a little too succinct, because I think it's also worth noting how [2] > In OOP, computer programs are designed by making them out of objects that interact with one another. I certainly wouldn't consider coupling state and function completely orthogonal to OOP though. I doubt most other programmers would either. I guess this might demonstrate the inertia of the so-called misinformation, but when the majority disagree with your definition of a term, you might want to step back and consider whether you're the one who's misinformed. [1] https://en.m.wikipedia.org/wiki/Programming_paradigm https://en.m.wikipedia.org/wiki/Programming_paradigm [2] https://en.m.wikipedia.org/wiki/Object-oriented_programming https://en.m.wikipedia.org/wiki/Object-oriented_programming
- PaulHoule 9y agoThis is an old article and much has changed. ORM frameworks in many languages such as Ruby, Python, Java, etc. have improved enormously since that time. I think they'll continue to improve as metaprogramming facilities improve, it is very feasible to convert an expression like 'x>2*y-7' from conventional programming languages to SQL and other query languages. Also there is immense interest in document databases such as CouchDB, Marklogic, Elasticsearch, DynamoDB, etc. These solve some of the problems of object-relational mapping, and we will someday see new frameworks.
- eropple 9y agoORM frameworks in the languages you listed primarily act as mutating state functions. So, to be honest: no, they haven't improved enormously at all. If your framework doesn't work first-and-foremost on immutable objects on which defined state transforms can be applied, you're putting your foot in a bucket that's very hard to extricate yourself from. Data mappers are pretty much the only reasonable mode, it seems. And they kinda suck, but they suck much less.
- specialist 9y agoORMs tip over once your queries have joins.
- WalterGR 9y agoWhich ORMs don't?
- bjourne 9y agoI came here to say that too. Back then ORM:s were clunky because the languages (Java) and techniques we were using were clunky. For example, the article talks about object identity and equality. Nowadays, you would try and design your data so that object identity doesn't matter because that works better with the functional paradigm. He also discusses how to map inheritance to database tables, but that is a moot point -- people don't use inheritance to model data anymore. The old "an Employee class is an instance of a Person class and has a reference to a Manager class which is also a Person-instance" thinking isn't used anymore.
- ThinkBeat 9y agoThe Vietnam analogy is just in bad taste and does not add much to the article.
- chazzeromus 9y agoAgreed, especially when it's around 1/3 of the article.
- averagewall 9y agoWe're trained not to compare things to the holocaust because it's in bad taste. Somehow lessons of how to treat other people don't translate from case to case. Us soldiers in Vietnam were supposed to be bad people doing inhumane things but US soldiers in Iraq somehow aren't. History keeps repeating and even though we remember it, we always think this time is special.
- ido 9y agoI'm most often hearing about the Iraq war in terms of "bad things <coalition forces> did". Not sure where you get the positive-sounding perspective (the most positive thing I ever hear is "Saddam was even worse").
- jorgec 9y agoSatan Hussein. He was considered even worst than Hitler and soldiers carried freedom to Iraq, how the army was called? freedom coalition force). It was the opposite.
- gleenn 9y agoInteresting article but I feel like the metaphor is a little shallow. There are plenty of troublesome topics in computer science that could be compared to Vietnam in the same way, it just feels a little excessive to compare those things to war. I did end up getting sucked into reading a lot of history about the actual war, turns out TFA should probably be split into two, one about the tech aspect and one about the pure history. The history section was well written.
- rosser 9y agoI've said for years that using an ORM is ultimately a piece of tech debt. Same point, far less inflammatory.
- andreasgonewild 9y agoA classic, the information about Vietnam isn't really relevant but I still find it interesting. Ran into this post back when I was busy implementing ORM's in umpteen different languages myself, and I remember that it motivated me to keep looking for better ways. Lately, I got the chance to sidestep the whole issue and implement my own persistence from the ground up in Snackis (https://github.com/andreas-gone-wild/snackis/tree/master/src/snackis/db https://github.com/andreas-gone-wild/snackis/tree/master/src...). It is still based on tables and records, but having them available as first class objects helps bridge the gap considerably.
- graycat 9y agoAt one time, I was in that object, relational, etc. stuff. Some people wanted all that stuff combined into some one, unified thingy. My conclusion: The whole was a mess. Better just to leave the separate pieces separate. One of the pieces was, sure, relational data base. Then there was the international work on CMIS/P -- IIRC common management informaiton system/protocol. This work seemed to want to model the world and everything in it, but really the goal was how do define and specify data for real time computer and network system management. This work was object oriented and, thereby, open to a lot of confusion: Really, what the work was talking about was just some data, say, describing a printer. So, there be fields with data -- character strings, numbers, arrays, etc. All it was was just data; that is, there was no associated code; no subroutines or functions to call; no applications programmer interfaces (API). The object part was that the definition of data from/for printer A could draw from, inherit from, the definition from printer B, etc. The next part was something we called Resource Object Data Model (RODM). So, the idea was that in real time management of server farms and networks, there could be several different programs trying to manage different aspects of the work, communicating with the same computer or network node, and causing conflicts. So the idea was to have a system, RODM, to present to all the programs trying to manage a single view of the servers and networks to be managed, a single view that would handle locking, exclusive access, cache data from the servers and networks, etc. So, RODM was a hierarchy, say, something like a file system hierarchy. At the leaves were objects that described parts of the servers or networks. The objects were active in the sense that they could run their own, if you will threads of execution, set timers, respond to timers, send and receive messages with other objects, the servers, the networks, programs doing the management, etc. All the hierarchy and objects were dynamic in the sense, much like in a file system, they could be created, changed, and deleted all during real time operations. RODM had some curious, tricky stuff: Could reserve an address space just for data. An address space for code could jump into another address space for code and execute code there. Etc. One role for RODM was for programs to do system management based on AI (expert systems) to have RODM to talk to as model of the servers and networks being managed. It flopped. I contributed a little: Part of such management is detecting and correcting problems in real time. Some of the problems are ones never seen before. So, I worked up how to detect those problems, with known, adjustable false alarm rate, etc. So, that was to be a much better approach to anomaly and early problem detection than we could expect just from the usually intended uses of expert systems. But, really, as for the OP, it was all too complicated.
- jancsika 9y ago> Johnson’s successor, Republican $g(Richard Nixon), tried several tactics to bring pressure to the NVA/VC forces to bargain [...] One such tactic the author fails to mention was the successful effort to undermine Johnson's peace negotations by doing illegal covert dealings with the South Vietnamese through Nixon's underlings. Nixon was undermining the negotiations between the U.S. executive branch and North/South Vietnam when Nixon was still a candidate, encouraging the South to hold out until after the election. You can read about it and much more in Christopher Hitchens' "The Trial of Henry Kissinger." Regardless of one's opinion of Hitchens, he refers to unclassified documents and many other reputable sources in his section on this. The only reason I mention it here is because the author has attempted to flesh out an analogy with what I must assume were supposed to be the salient details of each item being compared. To do that and leave out the fact that a presidential candidate undermined the acting president's effort to end the war is quite strange. Also, I'd be interested to hear the author explain what "regular violations of nearby Laos and Cambodia" actually means.
- cariaso 9y agoIn case the author doesn't show up, I'll offer "There were more than 580,000 bombing missions on Laos from 1964 to 1973 during the Vietnam War. That's equivalent to one bombing mission every eight minutes, 24 hours a day, for nine years. Over two million tons of ordnance was dropped on the country, with up to 30 per cent failing to explode as designed." http://www.maginternational.org/the-problems/the-uxo-problem-in-laos-statistics/ http://www.maginternational.org/the-problems/the-uxo-problem... More than 40 years after the war, one-third of the country is still contaminated by unexploded ordnance — an ongoing cost of war that affects the Lao people daily. video at http://abcnews.go.com/International/americas-secret-war-laos-uncovered/story?id=41968017 http://abcnews.go.com/International/americas-secret-war-laos... also a worthwhile visit http://www.cambodialandminemuseum.org/ http://www.cambodialandminemuseum.org/ There may be many other violations, but I think that's a credible start.
- tome 9y ago> also a worthwhile visit http://www.cambodialandminemuseum.org/ http://www.cambodialandminemuseum.org/ That doesn't appear to be about Laos though?
- wcr3 9y agoah yes, "the vietnam of computer science." a classic. never forget. can't wait for "the holocaust of programming." heard good things about "ethnic cleansing and compiler theory" too. keep us posted.
- hueving 9y agoDon't forget the "9/11 of algorithmic complexity".
- est 9y agoI think the problem with ORM these days is leaky abstraction. Sometimes we have RDBMS but more the times we have Redis and shit. You can't organize all sources of data under the same umbrella and it's painful.
- sbierwagen 9y agoand the most memorable image of the war, that of streams of fleeing people seeking space on the Huey helicopter perched on the roof of the embassy. Common misconception. The roof in question was that of an apartment building a kilometre away from the embassy: https://en.wikipedia.org/wiki/22_Gia_Long_Street https://en.wikipedia.org/wiki/22_Gia_Long_Street
- plinkplonk 9y agoInteresting how "The Vietnam of ..." assumes the US viewpoint as the default. From the Vietnamese viewpoint, the war could (for example) be seen as underdog patriots resisting waves of invaders possessing an overwhelming material and technical superiority and utterly defeating them through sheer willpower and sacrifice, thus gaining a nation of their own. Which would make a paper titled "The Vietnam(War) of Computer Science" a description of some kind of breakthrough in CS, attained after a tremendous struggle. So yes, dumb analogy. The paper would read as well without the bullshit title.
- DalasNoin 9y agoBut i dont think the vietnamese would refer to it as the vietnam, but rather as the us invasion of computer science. :)
- plinkplonk 9y agoha! good point. From Wikipedia, the Vietnamese apparently refer to the war as the "Resistance War Against America" or "the American War" [1]. A CS paper named after this would be interesting. "ORMs - the CS Resistance War Against America" , or even "The America of Computer Science" :-P [1] From https://en.wikipedia.org/wiki/Vietnam_War https://en.wikipedia.org/wiki/Vietnam_War The Vietnam War (Vietnamese: Chiến tranh Việt Nam), also known as the Second Indochina War,[56] and known in Vietnam as the Resistance War Against America (Vietnamese: Kháng chiến chống Mỹ) or simply the American War,
- SiVal 9y agoYou mistakenly assume that all Vietnamese were on the same side in the war. Millions of Vietnamese lost that war to domestic forces who would never allow free speech, free elections, etc., armed by foreigners (Soviets) who never allowed free speech, free elections, etc. The Vietnamese who cut my hair here in Silicon Valley possess nothing remotely resembling what you naively call "the Vietnamese viewpoint."
- plinkplonk 9y ago
- TOGoS 9y agoWhy is everybody's nickname $g?
- Terr_ 9y agoPerhaps some JS script design to add Google or Wikipedia links that is malfunctioning?
- Zigurd 9y agoI like Android's Cursor and Adapter classes that skirt ORM, connecting query results to Android's support for the observer pattern. Most pubsub frameworks fail to do any better. Mostly because people don't realize how useful Cursor is.