开发者

Active record and Repository patterns together. Is It acceptable?

开发者 https://www.devze.com 2022-12-12 22:23 出处:网络
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 bu

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消