Here I am again with a follow up post in my series on fixing a real world legacy application. I’ve been continuing my work with NDepend and wanted to give an update on what it has helped me do. Just a small reminder: the application is a web application to make forecasts about the World or European championship football/soccer. You can read more about it in my first post. Mutable Statics I had a large class containing all the teams

In my series of fixing a real-world legacy application, I’ve already improved the code in some big blocks: updated Bootstrap introduced dependency injection removed unnecessary cruft added logging But fixing legacy applications often means making many smaller improvements. Many of these are often a matter of personal opinion. And when multiple developers do agree on an issue, they might not agree on a particular solution. The best way to avoid these nonconstructive discussions, is to have a tool to automate

This application contains absolutely no logging. In many legacy enterprise application, there usually is some logging, but it’s often not very useful. In some cases, there is no logging at all. This makes it hard to troubleshoot when things go wrong. In .NET, the first logging frameworks that come to many developer’s minds is log4net or NLog. I’d recommend NLog over log4net because the documentation seems better to me. In my position as consultant, I often encounter custom logging frameworks.

Continuing my series on fixing my real-world legacy application, I will now introduce dependency injection. First, I simply installed the Autofac.Mvc5,¬†Autofac.Mvc5.Owin¬†and Autofac.WebApi2.Owin NuGet packages. This changes nothing of course. So next, we tell ASP.NET to let Autofac handle the creation of the controllers. In our Startup class, we add: This is basically what’s in the Autofac documentation. Notice how we need to set up Autofac for both MVC and WebAPI. This is because this application is using both. I’m using

When I first started writing this app, I wanted to move fast. I found a JavaScript library that promised to connect my client-side code to my Entity Framework context very easily: Breeze. For some reason that I can’t remember now, I never ended up using very much of it, if anything at all. But I had never cleaned up the mess I had left behind. This is a typical example of how legacy code accumulates: components get added for small

This is a first step in my series on fixing a real-world legacy application. It focusses on updating Bootstrap, but the broader issue here is that you should update the components you are using. The application was using Bootstrap 3. Updating to version 4 was fairly easy. I first uninstalled the NuGet packages bootstrap.less, Twitter.Bootstrap and respond.js. I chose to use the Bootstrap CDN so all I need to do was: remove the Bundle in  my BundleConfig.cs file change the

For the FIFA World Championship of 2014, my friends and I wanted a website where we could “bet” on the games. Not for money, just for fun. In the past, we used an Excel file with some fancy formula’s. But then came the idea to write a web application. As the only developer, I accepted the challenge. It was done in a rush, with the technology of the time. Four years later, this gives me an excellent exercise for refactoring.

This is the third and final part in my short series on tackling legacy code. Previously, I wrote about general coding techniques, and about the organizational and operational requirements. I would like to close with some final thoughts. Technology isn’t the problem We developers can’t help but get enthusiastic about new technologies: languages, frameworks, libraries, techniques, etc. But more often than not, the problem with a legacy project is not the chosen technology or its age. Rather, it’s the way

In my previous post, I gave some insights into how you can start turning the legacy ship around. In the end, I talked about preconditions that should be fulfilled before you start. I’ll dive into those now. The organizational First and foremost, the organization must agree that tackling the legacy code is something they want to do. “The organization” can be defined on several levels: from the team to upper management. But the more support you have upwards, the better.

Legacy code is usually the code nobody likes to touch. It’s often complex, violates all kinds of best practices, has little or no tests, etc. Yet I find it very rewarding to work in legacy code. It takes a while, but when you start to tame that beast and understand its intricacies, it can actually be fun! But how do you start changing a legacy project, putting in modern standards, and making it maintainable? This article will explain some techniques