How To Accelerate Software Development By Automation

Here is a simple but effective general method for debugging complex application plus some C# example.

Photo by Lyman Gerona on Unsplash

Introduction

The process of debugging can be very slow in cases where each execution of the application takes a lot of time. One trick I usually use for accelerating the development process is implementing new features as separate modules that can be tested separately. Building a software in a modular way is always a good practice and it also can save debugging time. Only after testing the separate module separately and making sure that it is working well, I integrate it into the whole system and only then I test the new feature as a part of the entire system.

The trick of writing the new piece of code into a new separate module is good but not always possible because of the way in which the existing software is sometimes written. Additionally, sometimes I need to make a very small change in a very big system. In cases like this, testing the new code by itself is pointless and only testing the entire system is meaningful.

Adding Automation Code

Recently I had to solve some complex problem in some huge medical system. It was a multidisciplinary software system that was developed for years by several developers. Its 30GB source code folder contains hundreds of libraries and many third party dependencies. The most challenging part in the task was debugging it, because loading the application and navigating between its screens for getting to the relevant part of it took me about 10 minutes every time. So I decided to add some automation into it in order to ease my work. The huge software was written in C# with WPF but the technic I used can be applied with any other programming language.

I added into the solution a DLL project with a public singleton class in order that all the other parts of the system can access it. This singleton class is responsible for reading a CSV file with a set of parameters once the application is loaded and it allows any other module to check the values of these parameters. The CSV file is created in the first execution with default values in the same folder as the executable file. Once this infrastructure was ready I added many “if” statements all over the source code for allowing skipping many operations once some parameters are defined as “on” in the CSV file. This allowed me switching on and off some features by only changing the CSV file and without re-compiling in order to get quickly to the point which interested me.

Later I added into this DLL classes and functions for dumping data to files and for profiling and other things that helped me to debug the system.

The C# Code I Use

How To Use It

You can copy this code snippet from the following block:

string user = DebugValues.GetValue(“user name”, “user”);
string password = DebugValues.GetValue(“password”, “password”);
if (DebugValues.IsOn(“skip login”))
{
// add here code that fills the username and password fields
// and clicks the login button
}

After running the application at the first time and getting into the login screen, assuming the name of the executable is “test.exe”, a CSV file with the name “test.exe.debug.csv” will be created automatically in the same folder as the executable.

Now you can open this file using Excel or just any text editor.

Now whenever you want to skip the login screen, just change the value of “skip login” parameter to “on” (by changing cell B3). You may prefer using a simple text editor because saving a change into a CSV using Excel requires clicking “yes” 4 times before closing the file.

Make sure to close Excel before starting the application because otherwise it will crash because the file will be locked by Excel.

Conclusion

Originally published at https://www.orensifri.meddevsoft.com.

Software developer & architect. CTO at MedDev Soft

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