Hi Guys, I'm wondering how to implement and idea I've been kicking around.
I've come from a background using ActiveRecord patterns to create models that both
1) Store buiness logic
2) Save to the database
Generally speaking, I've seen the general idea referred to as
Datamapper
Domain Models
Datamapper + Domain Models
Even the repository pattern is vaguely related.
But my goal is to split business logic from the database implementaiton. Basically I've come to conclude that a Model != Table!
Consider a shopping cart as an example. It contains a list of products to purchase for a particular user. I'd like to represent the shopping cart as an object that stores and saves to other objects like Product and User. But the act of saving a Shopping cart, with the related logic of saving products and user data, should be split from actually running the requried series of database queries.
I've seen some ideas around using events like beforeCreate and afterCreate but that doesn't really split out buisness logic. It just seems to better organize it.