Source Code Deletion Anxiety

Source Code Deletion Anxiety

Editor’s note: Anxiety can be serious medical condition, while the author has written about anxiety here in relation to code, if you are experiencing real anxiety, please seek medical help. The following article is obviously not medical advice.

Image for post

Photo by Gift Habeshaw on Unsplash

Editor’s note: Anxiety can be serious medical condition, while the author has written about anxiety here in relation to code, if you are experiencing real anxiety, please seek medical help. The following article is obviously not medical advice.

Why you should delete a lot of source code without fear — as early as possible in your project!

Source code deletion anxiety is a disease in software developers leading to a lot of problems in the future as it produces unnecessary software clutter for you and others which must work with your codebase. Unfortunately, it cannot be cured by a physician prescribing the correct medication (as far as I know). In this article, I want to highlight the importance of deleting code, uncover the causes for code deletion anxiety, and how to cure it.

As a professional software developer for two decades I wrote and read a lot of source code in a multitude of textual and graphical programming and scripting languages such as LISP, C, C++, C#, GO, Java, Kotlin, MATLAB M-Script, LabVIEW, Python, JavaScript, PHP, Bash, Structured Text — to name only a few and you know what: I found a really dangerous emotion while programming (yes software development is not without emotions!):

Deleting source code you spent a lot of hours with feels painful.


Deleting source code others wrote feels scary.

That is interesting by itself. You are not cutting off your arm — you just remove lines in an text editor or sometimes whole files (in graphical languages this is similar). And this is indeed a very essential thing in software development. I observed this feeling in my own daily doing as well as in colleagues and friends. Sure, you should only remove code which is not necessary anymore. Or find similar sections and extract methods or classes from that. So, by the way, it is not always simple to decide what to remove and how to refactor without breaking the code! There could be interfaces or classes which are just complicating every access, duplicated code or other smells (here I refer to the great work of Martin Fowler¹ in the recommended reading section).

Why is it necessary to delete code?

This seems to be trivial. The same question arises why you should regularly clear out your basement or other similar places where you put all the things which you keep — in case of you need those someday. Software is a bit like a backyard — if you don’t watch weeds will thrive and overgrow all the beautiful flowers.

A software base is not maintainable anymore if there is a lot of unnecessary clutter in it. The architecture will suffer, it gets more and more difficult to fix bugs or integrate new features without breaking the code. Testing entangled parts is not simple.

I wrote that you should do it early: if you wait to long (say 10 years is a good time for that) then you will be confronted with a behemoth which you cannot fight anymore! And I really saw that. Run or throw it away and make it new — which is usually not an option. Software is usually not just written and can then stay forever in this state.

Even if you keep it feature stable — maintenance is always necessary: Toolchains change such as the permanent updates of the C++ standard or e.g. old Python 2 (deprecated, will not be maintained anymore) codes which need to be updated for running with Python 3. Libraries and APIs change or are updated to a newer version which are not compatible anymore.

There is a permanent stream of system and library updates possibly breaking the compilation or runtime behavior of your software. Sometimes a well-written and good maintained software library deprecates something your team has developed. Don’t repeat yourself and don’t reinvent the wheel! If the library fits your needs and could make your code way simpler and help you remove a lot of unnecessary code — than why not using it?

Causes of source code deletion anxiety

The emotions occurring when throwing out things from your basement might be similar to those when deleting source code. However, there is no eBay for selling deleted code parts. Probably the origin of this emotion is that:

1. It hurts to find out that the code you wrote is not necessary (anymore) — you think that you made a mistake and feel disappointed — or like a looser. You was not good enough to write a piece of software in one instance — a thing that is usually impossible. So that might just be an ego problem. After you put in a lot of hard working hours, love & brain you just delete what you did. That hurts!

2. You think you have misspend your own life-time or wasted time & money of your company or your customer because you wrote code that now seems to be superflous — you feel guilty.

3. You have fear that the code you are about to delete might have an important impact on the software you are maintaining or writing. This occurs especially in codes which is written by others — often we think that it might be better or necessary what others did. So unit tests and courage is what you need!

startup codecraft programming clean-code software-development

Bootstrap 5 Complete Course with Examples

Bootstrap 5 Tutorial - Bootstrap 5 Crash Course for Beginners

Nest.JS Tutorial for Beginners

Hello Vue 3: A First Look at Vue 3 and the Composition API

Building a simple Applications with Vue 3

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Offshore Software Development - Best Practices

To make the most out of the benefits of offshore software development, you should understand the crucial factors that affect offshore development.

5 Core Criteria for Selecting Software Development Company -

Check out these five criteria for the selection of your software vendor, and you will never regret having the wrong quality product made for you.

Software Developer vs Software Engineer — Differences: Bogus or Real?

In this article, see if there are any differences between software developers and software engineers. What you’re about to read mostly revolves around my personal thoughts, deductions, and offbeat imagination. If you have different sentiments, add them in the comment section, and let’s dispute! So, today’s topic…

ERP Software Services, POS Software Services , Application Development

Vinew Technologies focused majorly over ERP Software services and POS Software services, Web & Application development services & Woo commerce and Wordpress easy-to-use, multipurpose social media plugin for WordPress.

Developer or Engineer? Does It Make a Difference?

To summarise the main differences between the software developer and engineer: A developer executes. ... So the software developer is mainly focused on developing code that is a part of software development cycle. An engineer designs and plans applying the principles of engineering to software development.