Middle+
What principle does the Active Record pattern violate?
sobes.tech AI
Answer from AI
Single Responsibility Principle (SRP).
Active Record combines business logic and data access logic in one class. An Active Record object is responsible both for representing a row in a database table (data) and for operations on that data (saving, updating, deleting).
According to SRP, a class should have only one reason to change. In the case of Active Record, changes can be caused by either modifications in business logic or changes in the database structure, which violates the principle.