Jiang Zerui 极简-Live a little

Domain Analysis by Color Modeling

跑完步有点累,最近都在看财经方面的东西。确实大脑有点疲劳了。想写会代码放松一下心情,但是怕又钻了进去不好出来。所以翻译一篇刚刚读完的InfoQ发表的 这片文章《Domain Analysis by Color Modeling》。之所以想翻译它,是因为这个标题一看就感觉比较熟悉,在12年做达内教学体系信息话的时候,我在 做领域模型分析的时候就用到了色彩的变化,当时还写了篇文章,主要是用了四个颜色来区分不同的实体关系,以便区分不同实体来梳理业务流程。没想到多年后 的今天在这里看到这样的题目,打算翻译下来看看作者见解和用法。再次强调,英文为作者原文,中文为本人即兴随句翻译,不准确之处还望有心看到的人给予指出。

There are many methods for domain modeling, and different models may be produced for the same problem domain by applying different modeling approaches. So, I often hear such a question: How to ensure the correctness of the modeling process?		    有许多方法进行领域建模,不同的模型被创建用于同样问题的领域通过不同的建模方法。所以,我尝尝听见这样的问题:怎样确保一个正确的建模过程?
			      
It sounds like a straightforward question, but in fact it could be more complicated than we might expect. Firstly, we need to make clear what is the purpose of modeling. If it is just for describing problems, then there is no right or wrong modeling, but only differences resulting fromvarious point of views and perspectives; however, if we are talking about modeling an enterprise business system, then, the question should be changed to: “How can we ensure the model is capable of supporting the operation of an enterprise?” 这听起来像一个简单的问题,但实际上它比我们想象的要复杂。首先,我们需要清楚建模的目的。如果只是仅仅描述一下问题,那么这没有对或者错的模型,仅仅产生不同的结果从不同的观点和观察角度;然而,如果我们打算建一个企业业务模型,这个问题将是:我们怎样保证我们的模型能够确支持保企业的运营。

I would like to answer this question in brief with the following example.Before carrying out analysis and modeling, we have to know what the purpose of an enterprise business system is. Generally, the purpose of enterprise business systems is relevant to the demands of decision makers or management. The next step is to empathize with a manager, and to find out what his or her demands are exactly.Now, assume that you are a COO of an online eBook store. One day, a customer suddenly complains to you that one book he bought is missing, and the total price is miscalculated, that he overpaid some money. Before you make a commitment to settle the claim, you should firstly verify whether what the customer said is true. To do that, do you know what information is helpful for you to make an accurate judgment? 我很愿意通过下面的例子来回答这个问题。在我们开始分析建模的时候,我们通常不得不首先了解企业运营系统的目的是什么。通常来说,业务系统的目的总是与决策和管理相关。接下来就如同管理者一样去找到确切的需求。现在,假设你是一家在线图书销售商店的COO,一天,一个客户突然对你抱怨他买的一本书不见了,并且购买图书的价格也不对,导致这位客户多付了钱。在你承诺去解决这个问题前,你应该首先去验证一下这个客户是否说的是正确的。在做这件事情的时候,你知道什么样的信息能够帮助你去做一个正确的判断吗?

To put it simply, you need to know which books were ordered and how much money was paid by the customer, and which books were delivered actually by the bookstore. Unfortunately, due to the limitation of technology, you are unable to see what has happened. You don’t havedrive a time machine to drive and see. But fortunately, you don’t need to do so; instead, you can obtain the relevant information by checking the order form of the customer, the transaction record of your e-bank and the stub of express waybill delivered by your bookstore to the courier.  简单来讲,
 
You check the order form and the stub of the courier waybill, and you find out that the customer ordered the books three days before, and your bookstore already sent out those books the day before yesterday. Besides, you also learn from the order form that the customer ordered seven books in total, but on the waybill there is only information about address, parcel number, postage and weight, without any information relevant to books. And now, you think you should ask the distribution department for more details. 你检查了订单和快递公司运货单的存根,你发现

From the distribution department you find out details about the parcel based on its parcel number, and sure enough there are only six books. Besides, you find a delayed delivery order which indicates that due to stockout, one book bought by the customer is prepared to be delivered. 从物流部门你通过包裹号发现了一些包裹的相信信息
   
So, the remaining matter is payment. From the e-banking record, the customer paid a total amount of 132.5 excluding postage; the amount shown in the order form is also 132.5, which clearly indicating that the customer didn’t overpay.  所以剩下的事就是付款。
To ensure the correctness, you re-select those seven books on the website to see whether the price is right or not. However, it is surprising that the total amount is only 128.3. After a careful verification, you find out that one of the books is now on sales promotion. And now, the problem is when did the sales promotion start?

为了确保正确,你重新选择了这7本书看看是否价格是否争取。

The market department shows you a recent promotion plan, and you find that the book in question was on sales promotion from yesterday. That is to say, the customer placed the order before the sales promotion started. 市场部门提交给你一份近期的促销计划,你发现问题书记在昨天的促销当中。也就是说,这个客户在促销开始之前提交了订单。
   
And then, you might think you should make a phone call to your customer to apologize, to discuss book prices, and to explain the sales promotion. 接下来,你认为你应该给你的这个客户打一个电话说声抱歉来告知客户关于这本促销书价格的问题去解释一下这本书的促销。
Do you think this is too much for a COO? It is certainly a fictional example. But, what can we learn from it?

你不觉得对于COO来说他做的太多了?当然这是一个假设,但我们能从中学习到什么呢?

Any business event should leave traces in some form of data. Tracing events can be done by tracing the data. Just as it was described in the story above, you can’t go back to the past to see what on earth happened, but, by making use of the receipts, we can determine what happened to a certain extent. Then, when we chronologically order the data , we may infer what happened during a certain period of time. 任何业务事件都应该留下业务轨迹在相同的一条数据中,跟踪这个事件是否完成通过跟踪业务轨迹数据。就像上面描述的那个故事那样。

Why can the chain of evidence formed by data help us trace a business operation? That is because that data is not selected randomly. If we review the process of checking carried out by you as COO, we will find out that you firstly selected the order form and the waybill. If the customer made a mistake when placing the order, and the waybill shows that the company mailed seven books, then you are not liable for the careless omission. Therefore, the order form and the waybill are in fact the basis for legal liabilities of your enterprise. After you confirmed that the liability lies with your company, you checked the execution results of some processes using the parcel form, verifying whether the execution results of major business processes are correct. In other words, that data is the execution result of key processes supporting your business system.  为什么数据的证据链能够帮助我们追踪业务流程操作?这是因为数据不是被随机选取的。如果我们像COO那样重新回顾一下我们检查的过程,我们将发现我们首先选择的是订单和物流单。如果客户下单错误,物流会显示公司邮寄了7本书,你不太可能忽略这样的问题。  <img src="https://jiangzerui.github.io/public/asset/pic/1Picture2.jpg" style="width:60%;display:inline;text-align: center;" />
That data resulting from process execution helps us trace and analyze some urgent events without learning about process details. Not only in the case of the extreme example (complaint) given above, but also in any normal economic transaction we need to be clear about the following questions:
1. If I paid a sum of money, what are my rights?
2. If I received a sum of money, what are my obligations?

Those questions can be answered only if corresponding traces are captured by the business system. Therefore, one of the main purposes of an enterprise business system is to record the traces and use them to form a valid traceable chain of evidence.

Now let’s shift our perspective back to a professional IT service provider. In order to build a traceable chain of evidence in an IT system, as a business analyst, you should know what events are required to be traced in operation, and what traces are left by those events.

Generally, those traces have a common interesting feature: they are moment-intervals. Finding out those moment-intervals is the first step of modeling. By slightly organizing the moment-intervals we will obtain the backbone of the whole domain model: 从流程执行产生的数据可以帮助我们

After determining the backbone, we need to enrich the model, enabling it to better describe our business concepts. At this time, we need to supplement the model with some entity objects. Entities are objects operating or being operated upon during moment-intervals, or places where moment-intervals happen. Therefore, there are three types of entity objects: party/place/thing. 在梳理好整体骨架后我们需要丰富这个模型,使其能够更好的描述业务概念 <img src="https://jiangzerui.github.io/public/asset/pic/1Picture4.jpg" style="width:60%;display:inline;text-align: center;" />

On this basis, we can further explore how those entity objects are involved in different processes. To do this, role will be required, because in some cases one type of entity can play different roles in different processes. For example, in the following diagram, Employee entity can be either Distributor or Marketing Director in different scenarios: 点点滴滴

And last, we can put more detailed descriptive information about entities into the description objects. For example, in the domain model shown in the following diagram, the Book object might only contain a very limited and fundamental information about a book, such as title and ISBN, and other descriptive information of the book (author, summary, table of content, etc.) can be put in Book Description object.   最后,

So far, we have got a domain model applying the “object modeling in color” technique. Those colors were initially suggested by Peter Coad and others in their book “Java Modeling In Color With UML”: pink for moment-intervals, green for entities (party/place/thing), yellow for roles, and blue for descriptions.

By briefly reviewing the above processes, it is not hard to find the order and key points of the modeling technique:

1.Firstly, identify events needed to be traced based on the demands coming from management and operations.

2.Secondly, identify traces and corresponding moment-interval objects which can represent the events needed to be traced.

3.Then identify entities (party/place/thing) related to the moment-interval objects.

4.For entities which can play different roles (often party entities representing people), extract role object for each role.

5.At last, supplement entity information with description objects.

In the first step, we take the management and operations goals as the starting point of the modeling process. Therefore, the entire domain model is in fact established around the question “how to effectively trace those goals”. Such a model would be capable of supporting the business operations.