English 中文(简体)
A. 领域设计方面受约束的实体
原标题:Entities across bounded contexts in Domain-Driven Design

I am trying to understand how entities operate in multiple bounded contexts.

Given an Employee of a Company. In (for example) the Human Resources context, this person has a name, surname, address, salary reference number, and bank account. But in the Accounting context all that is relevant is the salary reference number and bank account.

在会计方面,您是否拥有一个雇员实体和一个价值-Type(例如SalariedEmployee)?

class Employee
{
    public BankAccount BankAcountDetails { get; set; }
    public string FullName { get; set; }
    public Address ResidentialAddress { get; set; }
    public string SalaryRef { get; set; }
}

SalariedEmployee category (?) : 雇员的价值类型

class SalariedEmployee
{
    public SalariedEmployee(string salaryRef, BankAccount bankAcountDetails)
    {
        ...
    }

    public string SalaryRef { get; }
    public BankAccount BankAcountDetails { get; }
}

人力资源处是否在受约束的情况下归还这一信息? 或者,你在这两种情况下都使用“雇员”类别?

最佳回答

http://msdn.microsoft.com/en-us/library/j554200.aspx”rel=“noretinger”http://msdn.microsoft.com/en-us/library/jj554200.aspx:

Bounded Context是自主的组成部分,有自己的领域模式和自己的通用语言。 他们不应在一段时间内相互依赖,而且应该能够孤立地运作。 然而,它们是同一整体系统的一部分,确实需要相互交换数据。

如果你执行<<>CQRS 模式,你应在有拘束力的情况下利用这类通信活动:你的受约束的环境能够应对在受约束的环境下提出的事件,而你的受约束的环境可以公布其他受约束的情况。 各种事件(单向的、公布有关已经发生事件信息的非同步信息),使你能够保持你受约束的环境之间松散的交汇。

问题回答

如果它们严格分开,我将严格分开。 不同名称的两种不同类别。 每个人都有不同的属性。

如果人力资源能形成一种HRM。 雇员可以提出一种情况,即会计收回并产生会计。 雇员。

如果需要不止一种情况,某些事情当然可以仿照某个实体和另一个实体的价值。 从实体向价值标的转换通常简单明了,但从价值标的到实体可能不是这样简单明了的。 https://rads.stackoverflow.com/amzn/click/com/0321125215“rel=“nofollow noreferer”>Domain Driven Design,第337页:

The translation mechanism is not driven by the model. It is not in the bounded context. (It is part of the boundary itself, which will be discussed in context map.)

如果人力资源情况需要问及会计背景,则会成为一个令人困惑的问题。

我猜测,在这两种情况下我不会使用同一实体。 他们应该受到约束。 如果我不得不改变雇员班级以满足某种情况的需要,那么“受约束的背景”不会再受到约束。

I would use a value object. The trick is to define properly the value object. I see those are equivalent to "Data Types" object, like an integer is an integer. This is challengeable of course (int16,int32...). But let s assume it is the case. Is Employee a good candidate for a value object?.... I do not think so :(... You might not need the same set of information for Employee in bounded context. In another name the identification information of the employee is a better candidate (firstname, lastname, middlename...) This you could reuse in bounded context.

现在,服务层应归还这一价值目标吗? 我本人不会这样做。 我更希望在我的仓库中确定这种可变性。 分享Nhibernate的地图,或分享同样的预测/地图。

Hope this helps :)





相关问题
DDD - Returning entity in response to a service operation

I am new to domain driven development & have a simple question. If a service needs to generate some entity as a response to an operation then how should it be done? One of the ways is to inject ...

Domain Driven Design efforts in dynamic languages? [closed]

Are you aware of any DDD efforts in a dynamic language ? Practical resources on DDD tend to decrease quite dramatically when straying from enterprise-oriented solutions (a google search exluding C#, ....

Accessing domain objects in the view

If I don t want to expose the internal state of my Domain Objects, but I need to display them, I can think of three approaches. Which of these is the most "correct" (if any?). The "DTO/ViewModel ...

DDD screen cast question?

I wathced a screen cast on DDD by Greg Young the other day which spoke about persisting all state transitions of an object, instead of it s state when saved, then to load it "replay" all these ...

How to fluent-map this (using fluent nhibernate)?

I have two tables in my database "Styles" and "BannedStyles". They have a reference via the ItemNo. Now styles can be banned per store. So if style x is banned at store Y then its very possible that ...

热门标签