Sergi Papaseit Sergi Papaseit - 8 months ago 79
C# Question

What is the Humble Object pattern and when is it useful?

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.

I haven't had much luck Googling around either.

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

Answer Source

Maybe you should have tried binging.

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.