Half Cooked Code to Production

Over the past decade, we can see a dramatic improvement in digitalization. Most of us tend to use online platforms to solve our day to day needs and wants. When it comes to Software / Web development, over the years, the process of implementing such systems got different approaches and today we can see a huge improvement in developing such systems with advanced tools and techniques. No matter how technology has improved, Still, we have a valid question regarding time to market.

When it is the “time to market” most of the products build with the help of cross-functional teams and different group of people working with different features, different branches, some times one feature gets two to three months to complete. How do we keep all teams in the mainline and how we can do faster release to production? how do we release half-done features to production and test without breaking the existing system?

To address this issue, today in my blog post I’m going to give a brief idea, on how we can do a half-cooked feature release to production and test it without any advance pipeline.

Feature toggles is a handy tool to deal with it and the basic idea is to have a configuration file that defines a bunch of toggles for various features we have pending. The application then selects which feature should be enabled and disabled. Let’s see an example of how we can do feature toggle using ASP .Net Core Application.

To demonstrate this example, I have created a new Web API and you can find out on GitHub.

There are two endpoints, which one endpoint returns product price, and another endpoint will return product counts.

There were two features that were related to GetCount and GetPrice. Two teams specifically worked on these features. The team that worked on Get Count completed their feature, but they had to verify whether the implemented logic works as expected on production. On the other hand they had to roll back the feature in case there were any issues that took place. The team that worked on GetPrice had completed half of their work but will require a few more weeks to complete the remaining. According to this case, one team needs to test the feature, and the other needs to keep up to date with the mainline of the repo. How can they do a production release with partly done effort?

Let’s try feature toggling with Microsoft Feature Management Extention.

> Install-Package Microsoft.FeatureManagement -Version 2.0.0

Once you install the required package, register feature management service on your Stratup.cs

Create Feature class to get the reference of the feature we need.

Inject FeatureManager from Microsoft Feature Management Extention.

Now we good to go. Let’s check our feature enabling for production.

As you can see I have wrap GetPriceBasedOnMetrix() method and GetCountWithSomeLogic() with IsEnableAsync method. Here we configure our feature toggling. With our example, we need to hide the half-completed price feature and need to enable GetCount new logic on production. So let’s configure our toggles in appsetting.json

Boom! our half-cooked code is now ready to go production. We set the GetPrice feature to disable and GetCount feature enable. If any issues occurred with GetCount new logic, we just have to toggle features and disabled it.

In addition, there are few other handy features which provided by Microsoft Feature Management tool. You can use these where ever as required in your newly implemented code. Hope you all can understand the power of feature toggling. Are you blocked with a half-done feature? Do not wait and try out feature toggling. If any further clarification, you can find out me on LinkedIn

Senior Software Engineer | Self Learner

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store