Chapter 6. The New .NET Antipatterns

Out with the old! To modernize .NET applications and get the benefits of cloud native—remember, it’s about software that’s more scalable, more adaptable to change, more tolerant of failure, and more manageable—we need a different approach. How we built software a decade ago was a reflection of the use cases, technologies, and knowledge we had then. Although we don’t apologize for that, all of those aspects have evolved. And quickly! In this chapter, we take a look at a handful of things that we used to do with our .NET apps and why they now represent antipatterns.

These items are “antipatterns” because they make it more difficult for your software to behave in a cloud-native fashion. These patterns are not inherently awful, but they no longer reflect best practices. For each item, I call out why you should avoid it, and what you should do instead.

.NET Application Architecture Antipatterns

These antipatterns directly relate to how you build the functionality of your application. As you modernize your .NET software, these are things that demand refactoring.

In-Process State

ASP.NET makes it super easy to store and retrieve values across user requests. Are you planning on stashing customer-entered data through a multipage wizard experience? Just use the following:

Session["CustomerName"] = txtCustomerName.Text;

Although ASP.NET offers multiple storage options for session state, the default behavior is to store this information in the host server’s ...

Get Modernizing .NET Applications 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.