---
title: "NullObject.For<T> - As simple as it gets, but no simpler"
url: "https://osherove.com/blog/2008/5/10/nullobjectforlttgt-as-simple-as-it-gets-but-no-simpler.md"
canonical: "https://osherove.com/blog/2008/5/10/nullobjectforlttgt-as-simple-as-it-gets-but-no-simpler.html"
published: "2008-05-10T14:19:11"
updated: "2008-05-10T14:19:11"
tags: [".NET", "Agile", "Agile Related", "Art Of Unit Testing", "Unit Testing"]
author: "Roy Osherove"
description: "This NullObject Factory from Paul is very nice, simple and clean in its design. I really like it and I can see many uses for it, in parallel with working with your standard mocking framework or IoC Container…"
usage: "Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page)."
license: "https://creativecommons.org/licenses/by/4.0/"
---

# NullObject.For\<T\> - As simple as it gets, but no simpler

By Roy Osherove May 10, 2008 In [.NET](https://osherove.com/blog/category/net), [Agile](https://osherove.com/blog/category/agile), [Agile Related](https://osherove.com/blog/category/agile-related), [Art Of Unit Testing](https://osherove.com/blog/category/art-of-unit-testing), [Unit Testing](https://osherove.com/blog/category/unit-testing)

**Historical article** · Originally published May 10, 2008; technical details may be outdated.

[This NullObject Factory](http://www.paulstovell.com/blog/nullobjectfor) from Paul is very nice, simple and clean in its design. I really like it and I can see many uses for it, in parallel with working with your standard [mocking framework](http://www.typemock.com/) or [IoC Container Implementation](http://martinfowler.com/articles/injection.html).

here is a little usage example (last line):

```
var controller = new AccountController(         // Class I am testing
    mockCustomerRepository,                     // Class I am mocking
    NullObject.For<ILogger>());                 // Who cares about logging!
```

## More in .NET

[All posts in .NET](https://osherove.com/blog/category/net)

- May 17, 2008

    ### ["Swapping" instead of "Injecting" calls between classes](https://osherove.com/blog/2008/5/17/quotswappingquot-instead-of-quotinjectingquot-calls-between.html)

- May 15, 2008

    ### [Typemock Isolator 4.2.4 is out](https://osherove.com/blog/2008/5/15/typemock-isolator-424-is-out.html)

- May 6, 2008

    ### [Introducing LINQ To Regex](https://osherove.com/blog/2008/5/6/introducing-linq-to-regex.html)

- May 1, 2008

    ### [Please don't go (work for MS or Google)](https://osherove.com/blog/2008/5/1/please-dont-go-work-for-ms-or-google.html)


---

## About the author

**Roy Osherove**: Senior Solutions Architect at AWS working on AI for production and AI-driven development; author of The Art of Unit Testing and Elastic Leadership, with about 20 years of consulting and training on unit testing, TDD, team leadership and continuous delivery.

### Sites

- [RobotPaper](https://robotpaper.ai/): This blog: AI patterns and anti-patterns, AI and coding agents, and engineering leadership.
- [osherove.com](https://osherove.com): Roy's personal site. Author of The Art of Unit Testing and Elastic Leadership; consulting and training on unit testing, TDD, team leadership and continuous delivery, plus about 20 years of blog posts.
- [The Art of Unit Testing](https://www.artofunittesting.com): The Art of Unit Testing, 3rd Edition (Manning): readable, maintainable, trustworthy unit tests, plus TDD workshops in C#, JavaScript, Java and Kotlin.
- [5whys.com](https://www.5whys.com): Roy's writing on software team leadership: self-organizing teams, surviving chaos, learning mode and the Elastic Leadership model.
- [Pipeline Driven](https://pipelinedriven.org): Continuous delivery and DevOps practices: build patterns, pipeline-friendly testing, DevOps metrics and enterprise DevOps.
- [Elastic Leadership](https://www.elasticleadership.com): Elastic Leadership, Roy's framework for software team leaders (survival, learning and self-organizing modes).

### Social

- X: https://x.com/royosherove
- LinkedIn: https://www.linkedin.com/in/osherove/

### Contact

- Contact form: https://forms.gle/jQSx5KoXvrVA1JCK7

### License

Licensed under CC BY 4.0 — reuse, quote and adapt with attribution (Roy Osherove, link to the original page). License: https://creativecommons.org/licenses/by/4.0/
