Quantcast
Channel: michael f1337 » code
Viewing all articles
Browse latest Browse all 9

Separating behavior and persistence in models

$
0
0

Link: Separating behavior and persistence in models

— @engineyard via @lukebayes

Recall the Single Responsibility Principle: “There should never be more than one reason for a class to change.” As we commonly use them, ActiveRecord and DataMapper1 classes almost always violate this principle. There are usually at least two responsibilities handled by every AR/DM model: persistence and business logic. Carrying around that persistence behavior, and all the dependencies that go along with it, is what bloats and slows down our specs.


Viewing all articles
Browse latest Browse all 9

Trending Articles