DDD,反腐败层,如何做? [英] DDD, Anti Corruption layer, how-to?

查看:2148
本文介绍了DDD,反腐败层,如何做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

目前,我们必须建立一种基于遗留一项所述的应用程序。 code为旧的应用程序应该被扔掉和改写,但通常它 - 而不是改写,我们需要基地新的东西就可以了。最近,我们决定去DomainDrivenDesign路径。所以 - 反腐败层可能是我们的问题的解决方案。据我理解,应该是这种方式可能逐步改写旧的应用程序。

At the moment, we have to build an application which is based on a legacy one. Code for that old application should be thrown away and rewritten, but as it usually goes - instead of rewriting it, we need to base something new on it. Recently, we decided to go the DomainDrivenDesign path. So -- anti corruption layer could be a solution for our problems. As far as I understand, this way it should be possible to gradually rewrite the old application.

可是 - 我找不到任何很好的例子。我想AP preciate的任何信息。

But -- I can't find any good example. I would appreciate ANY information.

推荐答案

在我的特定实现,EmployeeAccessService被称为库。这的确是一个门面到反腐败层。它委托给EmployeeAccessAdapter。适配器取从旧模型(它从EmployeeAccessFacade获取)的对象,然后将其传递到EmployeeAccessTranslator从遗留模型变换对象到域对象在我的应用程序的模式。

In my particular implementation, EmployeeAccessService is called by a Repository. It's really a facade into the Anti-corruption layer. It delegates to the EmployeeAccessAdapter. The adapter fetches an object from the legacy model (which it gets from EmployeeAccessFacade),then passes it to the EmployeeAccessTranslator to transform the object from the legacy model to the domain object in my application's model.

EmployeeAccessService

public Employee findEmployee(String empID){
    return adapter.findEmployee(empID);
}

EmployeeAccessAdapter

public Employee findEmployee(String empID){
    EmployeeAccessContainer container = facade.findEmployeeAccess(empID);
    return translator.translate(container);
}

EmployeeAccessTranslator

public Employee translate(EmployeeAccessContainer container){
    Employee emp = null;
    if (container != null) {
        employee = new Employee();
        employee.setEmpID(idPrefix + container.getEmployeeDTO().getEmpID());
        ...(more complex mappings)

这篇关于DDD,反腐败层,如何做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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