<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
</head>
<body dir="auto">
<div>Another good article from an ex-coworker that keeps on making more and more sense the more projects I get into...</div>
<div><br>
</div>
<div><span style="font-family: '.HelveticaNeueUI'; font-size: 15px; line-height: 19px; white-space: nowrap; -webkit-tap-highlight-color: rgba(26, 26, 26, 0.296875); -webkit-composition-fill-color: rgba(175, 192, 227, 0.230469); -webkit-composition-frame-color: rgba(77, 128, 180, 0.230469); -webkit-text-size-adjust: none; "><a href="http://seldo.com/weblog/2011/08/11/orm_is_an_antipattern">http://seldo.com/weblog/2011/08/11/orm_is_an_antipattern</a></span><br>
<br>
Your mileage/opinion though may vary :)<br>
<br>
Sent from my really tiny device...</div>
<div><br>
</div>
<div>On Aug 18, 2013, at 8:12 PM, "Robert Collins" <<a href="mailto:robertc@robertcollins.net">robertc@robertcollins.net</a>> wrote:<br>
<br>
</div>
<blockquote type="cite">
<div><span>On 19 August 2013 14:22, Jay Pipes <<a href="mailto:jaypipes@gmail.com">jaypipes@gmail.com</a>> wrote:</span><br>
<span></span><br>
<blockquote type="cite">
<blockquote type="cite"><span>I'm completely with Joshua here - the ORM layer is more often than not</span><br>
</blockquote>
</blockquote>
<blockquote type="cite">
<blockquote type="cite"><span>a source of bugs and performance issues.</span><br>
</blockquote>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<blockquote type="cite"><span>If used improperly, yep.</span><br>
</blockquote>
<span></span><br>
<span><a href="http://www.codinghorror.com/blog/2006/06/object-relational-mapping-is-the-vietnam-of-computer-science.html">http://www.codinghorror.com/blog/2006/06/object-relational-mapping-is-the-vietnam-of-computer-science.html</a></span><br>
<span></span><br>
<span>There is no proper use of an ORM.</span><br>
<span></span><br>
<span></span><br>
<blockquote type="cite">
<blockquote type="cite"><span>We don't use the SQLAlchemy ORM for cross-SQL-DB support - thats a</span><br>
</blockquote>
</blockquote>
<blockquote type="cite">
<blockquote type="cite"><span>lower layer. It's the model objects themselves that we use the ORM</span><br>
</blockquote>
</blockquote>
<blockquote type="cite">
<blockquote type="cite"><span>for, and we could use SQLAlchemy's lower layers but not the ORM.</span><br>
</blockquote>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<blockquote type="cite"><span>Hmmm, not quite... see below.</span><br>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<span></span><br>
<blockquote type="cite">
<blockquote type="cite"><span>An alternative I think would be better would be to scrap the use of</span><br>
</blockquote>
</blockquote>
<blockquote type="cite">
<blockquote type="cite"><span>the SQLAlchemy ORM; keep using the DB engine abstraction support.</span><br>
</blockquote>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<blockquote type="cite"><span>Just keep in mind that the Session and Query objects and their related APIs</span><br>
</blockquote>
<blockquote type="cite"><span>are in the SQLAlchemy ORM, not the SQLAlchemy Core.</span><br>
</blockquote>
<span></span><br>
<span>Ok, so either it's not a bright line, or we'd need to have an</span><br>
<span>alternative thing - not just a reimplementation either, cause that's</span><br>
<span>pointless.</span><br>
<span></span><br>
<blockquote type="cite"><span>But sure, ok.</span><br>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<blockquote type="cite"><span>But then I guarantee somebody is gonna spend a bunch of time writing an</span><br>
</blockquote>
<blockquote type="cite"><span>object-oriented API to the model objects because the ORM is very useful for</span><br>
</blockquote>
<blockquote type="cite"><span>the data modification part of the DB interaction.</span><br>
</blockquote>
<span></span><br>
<span>!cite - seriously...</span><br>
<span></span><br>
<blockquote type="cite"><span>Because people will complain about having to do this:</span><br>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<blockquote type="cite"><span>conn = engine.connection()</span><br>
</blockquote>
<blockquote type="cite"><span># instances is the sqlalchemy Table object for instances</span><br>
</blockquote>
<blockquote type="cite"><span>inst_ins = instances.insert().values(blah=blah)</span><br>
</blockquote>
<blockquote type="cite"><span>ip_ins = fixed_ips.insert().values(blah=blah)</span><br>
</blockquote>
<blockquote type="cite"><span>conn.execute(ip_ins)</span><br>
</blockquote>
<blockquote type="cite"><span>conn.execute(inst_ins)</span><br>
</blockquote>
<blockquote type="cite"><span>conn.close()</span><br>
</blockquote>
<span></span><br>
<span>This strawman is one way that it might be written. Given that a</span><br>
<span>growing set of our projects have non-SQL backends, this doesn't look</span><br>
<span>like the obvious way to phrase it to me.</span><br>
<span></span><br>
<blockquote type="cite"><span>instead of this:</span><br>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<blockquote type="cite"><span>i = Instance(blah=blah)</span><br>
</blockquote>
<blockquote type="cite"><span>ip = FixedIp(blah=blah)</span><br>
</blockquote>
<blockquote type="cite"><span>i.fixed_ips.append(ip)</span><br>
</blockquote>
<blockquote type="cite"><span>session.add(u)</span><br>
</blockquote>
<blockquote type="cite"><span>session.commit()</span><br>
</blockquote>
<blockquote type="cite"><span></span><br>
</blockquote>
<blockquote type="cite"><span>And so you've thrown the baby out with the bathwater and made more work for</span><br>
</blockquote>
<blockquote type="cite"><span>everyone.</span><br>
</blockquote>
<span></span><br>
<span>Perhaps; or perhaps we've avoided a raft of death-by-thousand-cuts</span><br>
<span>bugs across the project.</span><br>
<span></span><br>
<span>-Rob</span><br>
<span></span><br>
<span>-- </span><br>
<span>Robert Collins <<a href="mailto:rbtcollins@hp.com">rbtcollins@hp.com</a>></span><br>
<span>Distinguished Technologist</span><br>
<span>HP Converged Cloud</span><br>
<span></span><br>
<span>_______________________________________________</span><br>
<span>OpenStack-dev mailing list</span><br>
<span><a href="mailto:OpenStack-dev@lists.openstack.org">OpenStack-dev@lists.openstack.org</a></span><br>
<span><a href="http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev">http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev</a></span><br>
</div>
</blockquote>
</body>
</html>