Active record pattern: Difference between revisions

Content deleted Content added
Distributed systems: deleted section as it was complete nonsense, it's very much possible to update only some fields of a record - it does not matter whether the code for it is in the record itself or in a separate controller.
Tag: section blanking
Criticism: Deleted section on testability, because it is nonsense. It does not matter if the database operations are in the same file as the record or in a separate controller - in both cases the coupling (with respect to the unit under test) is exactly the same. You need to mock the database layer anyways, no matter where the DB access methods are located.
Line 31:
== Criticism ==
 
=== TestabilityLarge Files ===
Because the data and the database access methods are in the same file, those files end up being bigger.
Due to the coupling of database interaction and application logic when using the active record pattern, unit testing an active record object without a database becomes difficult. These negative effects on testability of the active record pattern can be reduced by using [[mock object|mocking]] or [[dependency injection]] frameworks to substitute the real data tier with a simulated one.
 
=== Single responsibility principle and separation of concerns ===