目前,我们必须构建一个基于遗留应用程序的应用程序。旧应用程序的代码应该被丢弃并重写,但通常情况下 - 我们不需要重写它,而是需要在它的基础上添加一些新的东西。最近,我们决定走 DomainDrivenDesign 路径。所以——反腐败层可以解决我们的问题。据我了解,这种方式应该可以逐步重写旧应用程序。
但是——我找不到任何好的例子。我将不胜感激 任何信息。
最佳答案
来自 DDD book (Domain-Driven Design: Tackling Complexity in the Heart of Software)通过埃里克埃文斯:
The public interface of the ANTICORRUPTION LAYER usually appears as a set of SERVICES, although occasionally it can take the form of an ENTITY.
稍后
One way of organizing the design of the ANTICORRUPTION LAYER is as a combination of FACADES, ADAPTERS (both from Gamma et al. 1995), and translators, along with the communication and transport mechanisms usually needed to talk between systems.
因此,您可以通过查看建议的 adapter pattern 来找到示例。和 facade pattern .
我将尝试解释 Eric Evans 所说的话,您的反腐败层将作为服务出现在您的层之外。因此,在反腐败层之外,其他层将不知道他们正在与反腐败层“说话”。在该层内部,您将使用适配器和外观来包装您的遗留信息源。
有关反腐败层的更多信息:
关于architecture - DDD,反腐败层,如何做?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/909264/