Tuesday, July 3, 2007

ADO.Net Entity Framework and persistence ignorance



I read an ADO.net Entity Framework blog post and realized that those guys don’t fully understand why people are so concerned about lack of persistence ignorance in ADO.net Entity Framework.

Separation of concerns and single-responsibility principle (a.k.a. cohesion) are very important concepts in OO-design. Basically, you want to keep classes, functions, etc. focused so that there is only one reason for them to change. If your domain classes aren´t fully persistence ignorant you have 2 reasons for a business class to change. First, when you need to change the persistence logic, and second, when you need to change the business rules. This “violates” the SRP.

If your domain classes are fully persistence ignorant, it makes them more testable. If they are too tightly coupled to persistence mechanisms, how do you test them? Objects are not just data containers. They also contain behavior and business rules. Testing will be a nightmare if you can’t test behavior without persistence.

Msdn blogs had also an interesting thread.

No comments:

Post a Comment