|
|
|
|
|
by vidarh
4963 days ago
|
|
I find it peculiar that anyone would describe ActiveRecord that way. In my eyes it's a behind-the-curve ORM based on the most basic ORM pattern available from Fowler's "Enterprise Application Architecture", and it seems most of the people _using_ AR never read it and have not thought at all about the tradeoffs vs. other ORM patterns (such as Data Mapper ; before anyone mentions the Ruby DataMapper ORM: That one doesn't actually implement the Data Mapper pattern). I particularly dislike the way it tends to result in code that is littered with leaky database abstractions where schema details tends to find its way into peoples controllers and views because it encourages people to call AR methods on model objects directly instead of even trying to encapsulate. Ruby is my favorite language, but Active Record is one of the things I hold greatly against Rails, not only for AR itself, but for the inspiration it provided to many other Ruby ORM's, that while they may improve on various aspects still to a large extent also end up encouraging leaking implementation details for your models all over the place. It'd be great if even 10% of the people using (and writing, it would seem, given that e.g. the Ruby ORM "Data Mapper" doesn't implement the Data Mapper pattern at all) these ORM's actually read the relevant chapters of EAA and pondered a bit on how it related to their applications. |
|
I wasn't aware Fowler is a required reading for anything(or I would say even beneficial) for _anything_, let alone AR.
> I particularly dislike the way it tends to result in code that is littered with leaky database abstractions where schema details tends to find its way into peoples controllers and views
Your whole rant doesn't have anything concrete I can respond to. How does schema details creep into controllers and views?
> because it encourages people to call AR methods on model objects directly instead of even trying to encapsulate.
Ummm. What? I don't understand. Are you proposing person.save is wrong and save should be abstracted?
> Ruby is my favorite language, but Active Record is one of the things I hold greatly against Rails, not only for AR itself, but for the inspiration it provided to many other Ruby ORM's, that while they may improve on various aspects still to a large extent also end up encouraging leaking implementation details for your models all over the place.
More rant. Still nothing concrete. AR maps the whole table, and if you are using AR, you should know that. If you need to map parts of the table, or compose parts from various tables as one object, use something else. Not every tool has to solve every problem.