O'Reilly logo

Professional ASP.NET MVC 2 by Rob Conery, Scott Guthrie, Scott Hanselman, Phil Haack, Jon Galloway

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 11. Testable Design Patterns

Now that you know how ASP.NET MVC works and (hopefully) understand the basics of Test Driven Development (TDD), it's time to jump into something more concrete: How can you structure your application to be a bit more testable and, moreover, maintainable? Understanding testable development patterns will allow you to work with one of the core strengths of ASP.NET MVC — testability. It should be noted here (and will be noted several more times in this chapter) that the term testability refers solely to your ability to test the code you write — not specifically to TDD, which we covered in the previous chapter. So, if you're thinking that we the authors are going to use this chapter as a TDD soapbox, you can rest assured that we're not.

While it might seem that we're pushing testability as the end goal of these patterns, it really is not the ultimate goal. This chapter contains coverage of some timeless object-oriented design principles that promote low coupling and high cohesion in your code. These principles help to ensure that your code is easy to change and not brittle. It helps to future-proof your code by ensuring that code is extensible from the outside. Testability — the ability to test your code easily — just happens to be a nice side effect of following these principles. Testability is also a form of verification that your code has these positive traits such as loose coupling. We understand that when discussing architecture, there be dragons ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required