Persistence ignorance in Rails. ActiveRecord 6 and beyond!

102 views
Skip to first unread message

Laerti Papa

unread,
Feb 3, 2020, 10:39:47 PM2/3/20
to Ruby on Rails: Core
Hi guys,

thank you for your effort so far and for your contribution.  

I've been playing around with DDD concepts lately and trying to apply them to Rails. It's been super annoying and frustrating trying to fight the framework to apply them especially when it comes to **Persistence ignorance**. It would be nice if the framework supported that out of the box either with a DSL likeish framework or configuration files. Also to have a more safe typing approach regarding data attributes I have to either implement it myself or use existing libraries like dry-rb or something.   

I was curious why so many years we don't decouple active record into two pieces. One to keep it as is. Second, allow users to decouple entities and data access objects and have a framework that will support them in better domain modeling without having to write much-supporting code to do so. 

I would appreciate any thoughts.

Best
LP




William T. Nelson

unread,
Feb 9, 2020, 10:24:11 PM2/9/20
to Ruby on Rails: Core
Building this capability into Rails would be contrary to the current project philosophy, so don't expect it soon.

However, Ryan Bigg has been working on similar features recently. See his reports here: https://ryanbigg.com/2020/02/rom-and-dry-showcase-part-1

Laerti Papa

unread,
Feb 10, 2020, 2:14:32 PM2/10/20
to Ruby on Rails: Core
Thank you for your reply, 

I understand that it is against the active record philosophy, it would be nice though to support both patterns and let the developer choose. I end up writing a lot of code every time I use AR only as the persistence on top of a repo instance. 


Thanks again.
LP

Pedro Fernandes Steimbruch

unread,
Feb 18, 2020, 9:28:32 AM2/18/20
to rubyonra...@googlegroups.com
Just my two cents here.

Do not waste time trying to apply code concepts (factories, repositories, etc.) from the Eric Evans book, if you think you are DDD only by using those, you are doing it wrong.
DDD is much more about Crunching Knowledge, Ubiquitous Language, Bounded Contexts and converging these to express your domain on your model always evolving to a deeper insight.

DDD is about tackling complexity on your software. Isn't writing a lot of code just to implement *Persistence Ignorance* increasing the complexity of what you have?

Enjoy what ActiveRecord gives you in a healthy way.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-core/ec331d07-d81a-45eb-a9e8-eb43728be750%40googlegroups.com.

Kasper Hansen

unread,
Feb 18, 2020, 12:07:33 PM2/18/20
to rubyonra...@googlegroups.com
Well said, Pedro. I don’t think there’s much interest in adding the repository pattern to Active Record.

--
Kasper
On 18 Feb 2020, 15.28 +0100, Pedro Fernandes Steimbruch <pedrofst...@gmail.com>, wrote:
Just my two cents here.

Do not waste time trying to apply code concepts (factories, repositories, etc.) from the Eric Evans book, if you think you are DDD only by using those, you are doing it wrong.
DDD is much more about Crunching Knowledge, Ubiquitous Language, Bounded Contexts and converging these to express your domain on your model always evolving to a deeper insight.

DDD is about tackling complexity on your software. Isn't writing a lot of code just to implement *Persistence Ignorance* increasing the complexity of what you have?

Enjoy what ActiveRecord gives you in a healthy way.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-co...@googlegroups.com.

Laerti Papa

unread,
Feb 21, 2020, 2:25:08 PM2/21/20
to Ruby on Rails: Core
I don't think that using tactical patterns in DDD should be avoided. I agree that AR is awesome but expressing the domain when you involve persistence you have conflicts. As well said evolving your model should not affect my persistence layer. 

Thanks for the feedback both much appreciated.

Best
LP

On Tuesday, February 18, 2020 at 6:07:33 PM UTC+1, Kasper Timm Hansen wrote:
Well said, Pedro. I don’t think there’s much interest in adding the repository pattern to Active Record.

--
Kasper
On 18 Feb 2020, 15.28 +0100, Pedro Fernandes Steimbruch <pedrofst...@gmail.com>, wrote:
Just my two cents here.

Do not waste time trying to apply code concepts (factories, repositories, etc.) from the Eric Evans book, if you think you are DDD only by using those, you are doing it wrong.
DDD is much more about Crunching Knowledge, Ubiquitous Language, Bounded Contexts and converging these to express your domain on your model always evolving to a deeper insight.

DDD is about tackling complexity on your software. Isn't writing a lot of code just to implement *Persistence Ignorance* increasing the complexity of what you have?

Enjoy what ActiveRecord gives you in a healthy way.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonra...@googlegroups.com.
On Mon, Feb 10, 2020 at 4:14 PM Laerti Papa <laerti...@gmail.com> wrote:
Thank you for your reply, 

I understand that it is against the active record philosophy, it would be nice though to support both patterns and let the developer choose. I end up writing a lot of code every time I use AR only as the persistence on top of a repo instance. 


Thanks again.
LP


On Monday, February 10, 2020 at 4:24:11 AM UTC+1, William T. Nelson wrote:
Building this capability into Rails would be contrary to the current project philosophy, so don't expect it soon.

However, Ryan Bigg has been working on similar features recently. See his reports here: https://ryanbigg.com/2020/02/rom-and-dry-showcase-part-1

On Monday, February 3, 2020 at 9:39:47 PM UTC-6, Laerti Papa wrote:
Hi guys,

thank you for your effort so far and for your contribution.  

I've been playing around with DDD concepts lately and trying to apply them to Rails. It's been super annoying and frustrating trying to fight the framework to apply them especially when it comes to **Persistence ignorance**. It would be nice if the framework supported that out of the box either with a DSL likeish framework or configuration files. Also to have a more safe typing approach regarding data attributes I have to either implement it myself or use existing libraries like dry-rb or something.   

I was curious why so many years we don't decouple active record into two pieces. One to keep it as is. Second, allow users to decouple entities and data access objects and have a framework that will support them in better domain modeling without having to write much-supporting code to do so. 

I would appreciate any thoughts.

Best
LP




--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonra...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages