用于创建模拟器的软件设计模式
我当前的任务是等待来自后端(DB)的几个字段,然后在我这边修改它们。后端更改需要时间,同时,我想创建一个模拟器并开始我的更改。有人可以建议是否有一种设计模式,它可以帮助我为后端设计一个模拟器,然后在不进行太多代码更改的情况下,允许我移植到真实的后端值?
My current task is to wait for a couple of fields from the backend (DB) and then modify them at my side. The backend changes will take time and in the meanwhile, I want to create a simulator and start of with my changes. Is there a design pattern, somebody can suggest, which will help me design a simulator for the backend and later on, without much code changes, allow me to port to the real backend values?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
存根应该足够了。
(来自下面链接的 Fowler 文章)
流行的 Java 模拟框架包括:
有关模拟的其他文章:
A stub should be sufficient.
(From the Fowler article linked below)
Popular mocking frameworks for Java include:
Other articles on mocking:
完全模拟您的协作者的东西称为存根。您可以使用一系列框架轻松构建它:jMock、EasyMock、Mockito 等。
存根不是一种设计模式。这是开发、测试和原型设计的总体思路。
The thing that fully emulates your collaborator is called stub. You can build it easy with bunch of frameworks: jMock, EasyMock, Mockito, etc.
Stub is not a design-pattern. It is a general idea for developing, testing and prototyping.
看看mockito,它非常棒。基础知识是:
您可能还需要使用一些依赖注入,以便您可以真实地传递(在生产期间)或模拟(在测试期间)对象到函数。
Look into mockito, it is pretty great. The basics are:
You may also need to use some dependency injection so that you can pass in real (during production) or mock (during testing) objects to functions.