Chapter 12. Best practices

 

This chapter covers

  • Designing maintainable controllers, filters, and actions
  • Building maintainable views with minimum duplication
  • Designing and testing routes
  • Testing MVC components

Although the ASP.NET MVC Framework is young in the .NET space, the MVC pattern applied to web applications is not. We have presented thus far techniques already used in many other MVC Frameworks, but some areas in the ASP.NET MVC Framework require extra attention. The ASP.NET MVC Framework is open-ended and extensible for customization, but not all usage and customization is appropriate. Not every approach to solving a problem will lead to elegant, maintainable results. Many of the examples on the web work well for simple problems, but break down quickly in a large production application or slightly complex small applications. In this chapter, we examine the major feature areas and extension points of ASP.NET MVC to discover what parts to use, what parts to avoid, and how to get the most out of our design by following best practices.

12.1. Controllers

12.2. Views

12.3. Routes

12.4. Testing

12.5. Summary