为 WinForms MVP 应用程序实现业务对象

发布于 2024-12-02 19:41:48 字数 1024 浏览 3 评论 0原文

我正在从头开始构建一个新系统并致力于应用程序的设计。我正在寻找对我的域对象进行建模的可行方法。

关于该项目的一些细节 - 这将是一个相当大的数据输入 WinForms 应用程序,集成到 ESRI ArcMap(一个 GIS 应用程序)中。数据访问必须经过 ArcMap 自己的数据访问层 - 通过游标样式访问来检索和保存数据。获取数据不是问题,但据我所知,这排除了实体框架和NHibernate等ORM工具,因为我无法直接与数据库交互。

WinForms 应用程序将遵循 MVP 监督控制器 模式 - 视图将绑定到模型。演示者还将修改模型。因此,Domain 对象应该支持以下功能:

  • 更改通知
  • 更改跟踪。至少我想知道我的模型是否发生了变化。

到目前为止我的选择:

  1. 手工编写 POCOS。 +优点/-缺点:
    • +应该可行
    • +可以容纳业务逻辑
    • +可绑定
    • -大量的手工工作
      • -通过 INotifyPropertyChange 接口更改通知。
      • -通过 IsDirty 属性更改跟踪,该属性必须手动维护。
  2. 由 POCO 包装的 ADO.NET 数据集。 +优点/-缺点:
    • +“免费”更改通知
    • +“免费”更改跟踪
    • +可绑定
    • -感觉有点乱

我已经排除的内容:

  • 实体框架 - 我使用的是 .net Framework 3.5,所以没有代码优先支持。据我所知,处理域逻辑非常混乱——事件处理程序。

还有其他好的选择吗?也许代码生成(对工具有什么建议吗?),一些框架?智慧之言、建议?

I'm building a new system from scratch and working on the design of the application. I'm looking at viable approaches for modelling my Domain objects.

Some specifics about the project - this will be a rather large data entry WinForms application, integrated into ESRI ArcMap (a GIS application). The data access must go through ArcMap's own data access layers - The data is retrieved and saved via cursor style access. This is not a problem to get the data, but as far I know, this rules out ORM tools as Entity Framework and NHibernate, as I cannot interact directly with the database.

The WinForms application will follow a MVP Supervising Controller pattern - the View will bind to the Model. The Presenter will also be modifying the Model. So the Domain object should support the following:

  • Change notification
  • Change tracking. At the bare minimum I'd like to know if my model has changed.

My options so far:

  1. Write POCOS by Hand. +Pros/-Cons:
    • +Should be doable
    • +Can accomodate business logic
    • +Bindable
    • -Lots of manual work
      • -Change Notification through the INotifyPropertyChange interface.
      • -Change tracking via an IsDirty property, which must be maintened manually.
  2. ADO.NET DataSets wrapped by POCOs. +Pros/-Cons:
    • +Change notification "for free"
    • +Change tracking "for free"
    • +Bindable
    • -Feels kind of messy

What I have ruled out:

  • Entity Framework - I'm on .net Framework 3.5, so no Code First support. As far as I know, handling domain logic is very messy - event handlers.

Are there any other good options? Perhaps code generation (any suggestions on tools?), some Framework? Words of Wisdom, advice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

墨落画卷 2024-12-09 19:41:48

我的 POCO 只是“哑”数据传输对象,它们不包含任何业务逻辑。它们也不是我的模型,因为它们是另一组更接近我的 UI 的愚蠢对象。我只是将 DTO 中充满的数据泵入数据访问层,将它们传递到我的服务层以处理业务逻辑,但它们仅传输到我的演示器/控制器,以通过模型将我需要的足够信息泵入我的 UI 。对于您的场景,我认为这更符合逻辑,因为您必须通过 ArcMap 的数据访问层。您可以将数据保留在表示层中并在那里进行更改跟踪。

My POCOs are just "dumb" data transfer objects and they contain no business logic whatsoever. They also aren't my models as they are another set of dumb down objects that are closer to my UI. I just pump my DTOs full of data in my data access layer, pass them up to my service layer for processing business logic, but they are only transferred up to my presenters/controllers to pump just enough information I need in to my UI through models. For your scenario, I think this would be more logical since you have to go through ArcMap's data access layer. You can persist the data in your presentation layer and do change tracking there.

¢好甜 2024-12-09 19:41:48

阅读本书
这甚至比你需要知道的还要多

Read this book
It's even more than you have to know

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文