duanliaoyu8419 2013-04-02 17:47
浏览 73

如何设计这个领域模型?

So I've the following Domain:

  • Applications and Versions, they are actually software applications
  • Devices, the devices on which the applications are installed
  • Installed Applications on Devices
  • Notification Subscription by installed Applications

So far, I've end up with the following model:

  • Application entity, which is defined by a name, an os and a type
  • Version value object, which basically wraps version informations (major, minor, etc.)
  • Release entity, which is a composed object referencing an Application entity and embedding a Version value object
  • Device entity, which is identified by a serial number
  • NotitificationSubscription entity (to allow me to Query by attribute)

Now I'm wondering how to "associate" Device entity, Release and the NotificationSubscription because it should be associated to an "installed" Release on a Device and include some extra information (like an authentication token).

Given the limitation of my ORM (Doctrine2) & RDMS (MySQL) I'm stuck at how to find a good design.

Imagine the following workflow:

  1. I fetch the Device entity from Database identified by its Serial Number
  2. I determine if the Release the Device is running from is already associated with it, if no, I create an association
  3. I need then to add or remove a NotificationSubscription for the current Device Release association

My problem is I end up with much indirection.

To allow me to set extra data to the association, I created an Association Class which is itself an Entity referencing both a Device and a Release.

A device may have different Release installed and running on it, so for example, I don't know how to query the following information: "Fetches all the notification subscriptions for the current release for the current device"

I obviously added a method in a Repository findSubscriptionsByDeviceAndRelease($device, $release); which means that I can query this information by both using the repository and through the graph $device->getInstalledReleases()->filter($identifiedRelease)->getNotificationSubscriptions();

Any ideas?

  • 写回答

1条回答 默认 最新

  • dongliyun3301 2013-04-02 18:01
    关注

    Keep it simple: you don't need a domain model here, you just need a good entity-relationship model. You probably don't need Doctrine either, since sql queries should be simple enough.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度