-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
My experience tells me, that mixing database related behaviors with business behaviors (or any other behaviors, like representation, UI, etc) is a bad idea long-term, and is an AntiPattern.
To avoid that problem, we could split current base class into 2 ones, and give users a conscious choice, what they want to do with ActiveRecord, in each particular case:
ActiveRecord::DataStructure- a data structure, all data is exposed, common serialization methods, asto_h,to_json,to_yaml, etc. are implemented.- It has only
#save,#update,.find,.wherebehaviors (data storage related). - Any other behavior is forbidden (still need to figure out if it is possible to do at the code level).
- It has only
ActiveRecord::DomainObject- a domain object, all data is hidden, serialization is not possible, unless defined by hand as a custom behavior (probably not a good idea, though).- Data storage related behaviors are provided by internal instance of
DataStructure. - By default, no behavior is exposed. User is free to expose some or all of the data storage related behaviors by delegating to the internal
DataStructure. - User is free to add any business domain behavior.
- Data storage related behaviors are provided by internal instance of
WDYT?
Metadata
Metadata
Assignees
Labels
No labels