4 ms·
Ok, let me throw out a different perspective, why are you even using an ActiveRecord Model as your entities in the first place. That in itself violates the Sing
by programminggeek 14y ago
Ok, let me throw out a different perspective, why are you even using an ActiveRecord Model as your entities in the first place. That in itself violates the Single Responsibility Principle by attaching the persistance mechanism to the entity itself.
What if your entities were just objects that held data and did validation, but you let use case objects determine the behavior of your system beyond that? Data persistance at that point is literally persisting your entities to the DB.
Then you use the DB much more like you would a filesystem - to retrieve and save data. It doesn't determine your model, it just stores and retrieves your data.
So, you end up with 3 types of things in this system... entities, use cases, and data gateways.
Your data gateways can still use AR if you want, or something else, it doesn't matter.
This isn't my idea, Uncle Bob lays it out better than I can here: http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-architecture.html http://blog.8thlight.com/uncle-bob/2012/08/13/the-clean-arch...