什么是“大”的优势有波科与ORM? [英] What are the 'big' advantages to have Poco with ORM?

查看:184
本文介绍了什么是“大”的优势有波科与ORM?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个优点是在我脑海中,如果使用POCO类的ORM映射,就可以轻松切换从一个ORM到另一个,如果二者均支持波科。

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.

有一个ORM没有波科支持,例如映射与像DataObjects.Net奥姆属性做,是不是我的问题,因为还与波科支持欧拜和他们生成的代理机构,你必须知道,实体实际上是DAO对象绑定到一些背景/会话,例如序列化是一个问题,等等。

Having an ORM with no Poco support, e.g. mappings are done with attributes like the DataObjects.Net Orm, is not an issue for me, as also with Poco-supported Orms and theirs generated proxy entities, you have to be aware that entities are actually DAO objects bound to some context/session, e.g. serializing is a problem, etc..

推荐答案

POCO它是所有关于松散耦合和可测试性。

POCO it's all about loose coupling and testability.

所以,当你在做POCO你可以测试你的域模型隔离(如果your're做DDD为例)。你不必理会它是如何坚持。你不需要存根上下文/会话,以测试你的域名。

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.

另一个好处是,有较少漏抽象。由于持久性的担忧不会被迫领域层。那么,你是强制执行SRP原则。

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.

第三个优势,我可以看到的是,这样做POCO领域模型更加进化,灵活。比如果它被耦合到持久性可以添加新的功能更容易。

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.

我使用POCO,当我在做国内长途为例,但对于某些类型的应用程序,你不要的'T需要做DDD(如果你正在做基于应用的小数据),这样的关注是不一样的。

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.

希望这有助于

这篇关于什么是“大”的优势有波科与ORM?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆