What are the 'big' advantages to have Poco with ORM?

后端 未结 3 1154
暖寄归人
暖寄归人 2020-12-14 03:32

One advantage that comes to my mind is, if you use Poco classes for Orm mapping, you can easily switch from one ORM to another, if both support Poco.

Having an ORM w

3条回答
  •  时光说笑
    2020-12-14 03:56

    POCO it's all about loose coupling and testability.

    So when you are doing POCO you can test your Domain Model (if your're doing DDD for example) in isolation. You don't have to bother about how it is persisted. You don't need to stub contexts/sessions to test your domain.

    Another advantage is that there is less leaky abstractions. Because persistance concerns are not pushed to domain layer. So you are enforcing the SRP principle.

    The third advantage I can see is that doing POCO your Domain Model is more evolutive and flexible. You can add new features easier than if it was coupled to the persistance.

    I use POCO when I'm doing DDD for example, but for some kind of application you don't need to do DDD (if you're doing small data based applications) so the concerns are not the same.

    Hope this helps

提交回复
热议问题