Post by vinay KPHi Folks,
Just came across the question regarding what are the different design
patterns used in ActiveRecord library,
As of I know ORM is one of the design pattern used,
Is there any other design pattern used in ActiveRecord library?
--
Thanks with Regards,
Vinay KP
*'Work speaks louder than words'*
Oh, yes, there are others as you suspect. This is one of the reasons I
found it incredibly difficult to implement a system in Rails using Domain
Driven Design principles. I'm going to give you the answer rather than
saying "This is the list for Ruby, not for Rails" since you can use
ActiveRecord separately from Rails.
Active Record (PoEAA, 160) â (which is an example of a Domain Model (PoEAA, 116))
Association Table Mapping (PoEAA, 248) â has_many through (and the
deprecated has_and_belongs_to_many)
Foreign Key Mapping (PoEAA, 236) â belongs_to
Identity Field (PoEAA, 216) â the ubiquitous `id`
Lazy Load (PoEAA, 200) â the behavior that can lead to 1+N issues which is
overcome using eager loading
Query Object (PoEAA, 316) â technically, this is what ActiveRelation does
now for ActiveRecord
Repository (PoEAA, 322) â schema and the various database adapters
Single Table Inheritance (PoEAA, 278) â for ActiveRecord subclasses using
the `type` column
There are a few others that could be argued, but those are more than
enough. (Either 8 or 9 depending on how you want to count Domain Model.)
"PoEAA" is Patterns of Enterprise Application Architecture, by Martin
Fowler, Addison Wesley, 2003
-Rob
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>