TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Is the ActiveRecord pattern really so bad?

1 点作者 Jaigus超过 12 年前
I'm using the sqlalchemy expression language for a project, and feel the data-mapper pattern implemented in the orm wouldn't be a good fit for my project since the classes are pretty much isomorphic to the database's tables.<p>I've spoken to and read from people that resent ActiveRecord because it violates SRP, and states it doesn't scale well. Aside from making testing a bit more difficult and not strictly abiding by the OO principles, what are some serious disadvantages to the ActiveRecord approach? It seems relatively pervasive(I've seen it used in Amazon's new persistence solution and Google AppEngine).<p>I've been considering a dao/gateway pattern approach, but it just seems silly to create what feels like a layer of fluff for what AR makes very simple, intuitive, and feels more natural to code. I'd really appreciate some opinions on this, thanks.

1 comment

stevenwei超过 12 年前
Honesty, the ActiveRecord approach is fine for the vast majority of use cases - just consider the number of sites built on Rail's ActiveRecord or PHP's Doctrine. This is one case where getting things done is more important than theorist purity, IMO.<p>Have you looked into SQLAlchemy's declarative extension?