什么是谦卑的对象模式,当是它有用吗?谦卑、有用吗、对象、模式

由网友(人越尝越泛淡)分享简介:我读如何测试AsyncConrollers在ASP.NET MVC 并在那里他用卑微的对象的模式,而无需进入很多细节的文章,迪诺埃斯波西托。I was reading an article by Dino Esposito on how to test AsyncConrollers in ASP.NET MVC a...

我读如何测试AsyncConrollers在ASP.NET MVC 并在那里他用卑微的对象的模式,而无需进入很多细节的文章,迪诺埃斯波西托。

I was reading an article by Dino Esposito on how to test AsyncConrollers in ASP.NET MVC and in there he uses the "Humble Object" pattern, without going into much detail.

我还没有多少运气周围的Googling无论是。

I haven't had much luck Googling around either.

那么,什么是谦卑的对象模式?当会是有用的?

So, what is the Humble Object pattern? When would it be useful?

推荐答案

也许你应该尝试暴食。

基本上,你拉所有的逻辑到一个单独的对象,你可以很容易地测试 - 你的卑微的对象成为各地的可测试的对象包装程序;它只是不起眼的对象也有东西,是很难测试,比如异步服务或GUI类的依赖。我们的想法是要离开这么少的实际逻辑,你不需要测试它,所以不需要处理测试难以测试的依赖不起眼的对象。

Basically, you pull all the logic into a separate object which you can easily test - and your "Humble Object" becomes a wrapper around your testable object; it's just that the humble object also has dependencies on things that are difficult to test, like async services or GUI classes. The idea being to leave so little actual logic in the humble object that you don't need to test it, and so don't need to deal with testing the difficult to test dependency.

阅读全文

相关推荐

最新文章