Get your .NET stuff done the right way

 The .NET community has a bit of a black eye when it comes to well-designed, well-tested, reusable code.  For years, the Framework's reliance on Web Forms and its tightly-coupled architecture lent itself to a very cavalier approach to programming.  Certainly, not everyone is carefree with their work, but let's just say the path of least resistance is a popular one.


On Web Forms: you could bang out a simple website fast, and the robust compile-time checking and Intellisense prevent a lot of stupid mistakes from ever getting deployed.  It's one of the fastest ways to stand something up quickly.  It's also really easy to become a lazy developer with it and write bad code.  Far too often, simple turns to complex, and before you know it there is a six-year-old website with bolt-on features.  Other developers don't want to touch it, and it remains the ward of the original developer until the site is sunsetted or that dev leaves the company.

It's common to have high expectations of our developers, but it's easy to get complacent with development practices.

The development world has evolved since ASP.NET 1.0 and its immediate successors.  Web Forms don't really mesh well with SOLID design principles unless you basically dismantle them enough to separate concerns.  Our code has to be fast, efficient, and easy to change.  The last bit is very important; building a site in a rigid, inflexible way can double the time it takes to finish.

Enter ASP.NET MVC.  Years ago, Microsoft adamantly proclaimed that both Web Forms and MVC were here to stay, but then essentially stopped supporting it with what was going to be .NET 5 and instead became .NET Core 1.0.  It's technically still "fully supported" on .NET 4.6.  Hopefully, if you're a .NET developer, you're intimately familiar with MVC.

Use SOLID design principles SOLID is an acronym to help remember basic principles of object-oriented design.  Using these principles takes a "get it working" mentality and changes it to "what happens if there are changes?"

Test. One of the most important benefits of using MVC is easier testing.  Several test frameworks are available; if you're just getting started with unit testing in .NET then stick to the built-in testing framework in Visual Studio.  Ongoing code quality analysis can be done using SonarQube (we have a process that runs automatically by pulling from a Git repo), as well as via Visual Studio plugins like ReSharper.

Collaborate! Don't work in a silo.  Grab another developer and do some pair programming, or get a group of people together and do a code review.  Formal or informal, the point is to give constructive feedback to others and for them to provide the same to you.

Automate your builds and deployments.  Tools like Jenkins and TeamCity for builds and Octopus Deploy for deployment are invaluable, as they significantly reduce error.  Show me someone that deploys everything manually that has never missed a file and I'll show you a liar.