Active record and Repository patterns together. Is It acceptable?
I really like these two pattern开发者_高级运维s.
The drawback of Repository pattern is its cost(takes more time then Active record). Benefit is higher abstraction which really helps on complicated business logic.
The drawback of Active record is that lower testability(db interaction is required) and harder in handling complicated domain logic.
Is it acceptable to take the best of these two patterns to be used in the same application?
I was thinking about using Active record for simple CRUDs and Repository for complicated domain objects.
The idea behind this intention is to keep cost of code lower but still have a good code.
I don't think it's wrong but once you have a Repository component it doesn't seem more work to get the simpler domain objects to work with it too.
精彩评论