Appendix C. Best Practices

This book covers a multitude of topics in varying degrees of detail and offers a lot of advice. However, it is sometimes difficult to judge just how important any given piece of information is in the context of a long, technical description.

This appendix consolidates many of the best practices noted throughout the book into a single list, so you can tell at a glance whether you are following the popular and recommended patterns and practices set forth in this book.

Use the NuGet Package Manager to Manage Dependencies

The NuGet package manager is a great boon to developers and teams alike. Instead of spending loads of time checking to see if the projects that your application depends on have released new versions, let NuGet handle all of that for you!

If your organization has several teams that share common libraries, consider creating custom NuGet packages for those shared libraries and hosting a custom NuGet repository to provide more effective distribution and versioning.

Depend on Abstractions

Abstractions encourage loosely coupled systems with a healthy separation of contracts and implementations. Abstractions are easily interchanged, which not only provides easier maintenance but is also crucial to unit testing.

Avoid the New Keyword

Any time you employ the new keyword to create a new instance of a concrete type, you are—by definition—not depending on an abstraction. Though this is often not a problem at all (e.g., new StringBuilder(), new List<string>() ...

Get Programming ASP.NET MVC 4 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.