什么是Humble Object模式,什么时候有用? [英] What is the Humble Object pattern and when is it useful?

查看:1453
本文介绍了什么是Humble Object模式,什么时候有用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在阅读 Dino Esposito关于如何在ASP.NET MVC中测试AsyncConrollers的文章,在那里他使用谦卑对象模式,而不需要详细介绍。

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.

那么,什么是Humble Object模式?什么时候会有用?

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

推荐答案

有一个 xunitpatterns.com的详细说明

基本上,您将所有逻辑都拉到一个单独的对象中,您可以容易测试 - 您的谦卑对象成为可测试对象周围的包装;只是这个谦卑的对象也依赖于难以测试的东西,如异步服务或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.

这篇关于什么是Humble Object模式,什么时候有用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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