如何版动态的业务对象/数据? [英] How to version dynamic business Objects/Data?

查看:211
本文介绍了如何版动态的业务对象/数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在开发一种与业务相关的大量应用。您可以找到这些应用程序类似,一些ERP,CRM等。

We are developing a large applications which are related to business. You can find these applications similar to some ERP, CRM, etc.

现在我们有我们需要的所有被进行版本控制,用户输入的数据的要求。

Now we have a requirement that we need all the data which are entered by the user to be versioned.

例如:在某个时间点,用户需要看到什么是一个特定的采购订单变更历史

For example: at some point of time, the user would need to see what's the change history of a particular Purchase Order?

我要寻找一个非常通用的版本处理器(不是刚性),如果有的一些业务数据属性得到改变它可以处理甚至案件。这种单一版本的处理程序应该能够与几乎任何类型的业务对象/数据的工作。

I am looking for a very generic versioning handler (not rigid), which could handle even cases if some some business data attributes gets changed. This single versioning handler should be able to work with almost any type of business objects/data.

什么是最好的编程/数据库设计来处理这些。

What would be the best programming/database design to handle these.

任何想法或意见?

PS:我已经为我想程序员来招待这个线程将自己的想法加入了一些程序代码

PS: I have added some programming tags as I want programmers to entertain this thread and give their ideas.

编辑: 我要寻找一个非常优化的方式,有点类似于具有存储而不是存储对象的序列化/倾倒路比较众生。

I am looking for a very optimized way, somewhat similar to having diffs beings stored rather than storing the objects in a serialized/dumping way.

推荐答案

这可能只是合适的时间采取的纯功能慵懒的数据结构。

It may be just the right time to adopt purely functional lazy data structures.

在简单地说,这需要禁止你的对象的任何变异操作,即让所有的对象实例不变。然后你重新设计所有这些改变现有对象来创建新的对象实例的操作的根据的旧的。

In a nutshell, this requires banning any mutating operations on your Objects, i.e. making all your Object instances immutable. Then you redesign all the operations which change existing Object to creating new Object instance based on the old one.

例如,让你有一个订单实例,它包含订单项 S的服务,您需要添加具体订单项到该列表。你在这种情况下,做的是一个新的列表,而这又是通过创造订单新实例替换的的项目清单> 利弊 的荷兰国际集团新的订单项老列表。

For example, let you have an Order instance which contains a list of OrderItems and you need to add a specific OrderItem to that list. What you do in this case is creating new instance of Order by replacing its items list by a new list, which in turn is created by cons'ing the new OrderItem to the old list.

让我进一步说明的图片的例子。试想一下的存储的对象(让它是RAM或者关系型数据库,任何东西)的:

Let me illustrate that example further in pictures. Imagine a storage of objects (let it be RAM or relational database, anything):


Address | Object             | Created by
--------+--------------------+------------------------------------------
   1000 | list of OrderItems | empty list constructor
   1001 | Order              | Order constructor, uses address 1000
                  ...         
   1300 | OrderItem          | ...
   1501 | list of OrderItems | cons of addr 1300 to addr 1000
   1502 | Order              | replace order_items in addr 1001 by addr 1501

在这种方式存储数据的结构本身是持久性的(克里斯Okasaki阐述了这一点的他的论文,例如)。您可以通过以下只是其创建历史还原任何版本的对象;版本变得微不足道。只要记住要点:不发生变异数据,创建新实例,而不是

The very structure of storing data in this way is persistent (Chris Okasaki elaborates on this in his thesis, for example). You can restore any version of an Object by just following its creation history; versioning becomes trivial. Just remember the main point: don't mutate data, create new instances instead.

这篇关于如何版动态的业务对象/数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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