Getting something to work once is not hard

As I wrote in a post on where to get information, I have been switching to offline resources such as books as a source of information. I've probably bought too many physical books as of late but I am reading them! One book that I've started to read is Clean Architecture by Robert C. Martin, which is about software design. (The book argues that software design and software architecture are the same thing, so I'm just referring to it as a book on software design.) I've only read the first few chapters but I wanted to write about something mentioned in the introduction of the book:

Getting something to work - once - just isn't that hard.

It reminded me when I was first learning to program in Perl. Through sheer hacking, I would eventually get something to work; it really isn't difficult if you're as stubborn as I was. StackOverflow didn't exist back then (it was created in 2008) and solving a problem was an exercise in brute forcing all possibilities! I guess nowadays it's even easier to get something to work once given all the available resources, especially with foundation/large language models.

But getting something to work "nicely" is difficult. The book's main measure of "niceness" is whether software is easy to build upon and maintain, and if it is, this will maximise productivity. Getting software right is hard because it takes insight developed over time, it requires discipline and dedication, and most of all, it needs the passion of continually honing your craft.

As an aside, even if you're a computational biologist who is focused on getting results and publishing papers, try spending a little time learning about different programming paradigms, how to use version control effectively, or even becoming more efficient with your text editor/shell/working environment. For example, I've recently switched to using Oh My Zsh and just the default features that come with it (i.e. it comes with batteries included) have been super useful; if you want more features there are many additional themes and plugins provided by the community. For example, the default git aliases have helped me type much less; git branches are shown in the prompt, which now also shows whether changes have been made and this has helped me work on the right branch; there's completion for when I need to switch branches, etc. Most of my work is done via the terminal and now that I look back, it seems silly that I never took some time to become more efficient with the terminal. Like I said, it's really a mindset.

Now getting back to the topic of getting code to work; we shouldn't settle on just getting something to work once because at some point in the future you or someone else will need to come back to your code to reproduce your work and/or build upon it. If you haven't taken the time to follow best practices, it's going to be time-consuming and tiresome to reproduce and update. The first few chapters also touches on the balance between functionality (getting something to work) and maintainability (easy to change) and demonstrates with edge cases why one is more important than the other. If code is fully functional but unmaintainable, it's pretty much useless. (Nothing really is unmaintainable but in this context it means that it's too costly in terms of time and money. In these cases, you often find it easier to just start from scratch because it takes too long to understand what was done.) On the other hand, if code is easy to change, then even if it has missing functionality this can be added on later. Therefore one should focus on design too and not simply aim for getting something to work just once.

I'll finish the post with another related tip from Clean Architecture, which is don't believe that writing messy code will allow you to go faster in the short term and that it will only slow you down in the long term. The fact is that making messes is always slower than staying clean. Even if you promised yourself that you'll clean the code up later when you have more time or are less busy, you probably won't. In the past, I have lied to myself on more than one occasion about cleaning up code later. The only way to go fast, is to go well.


This post was sponsored by Ecodyst:

Ecodyst's innovative metallic condensers are a game-changer. They not only boost your recovery rates, but also champion eco-friendly practices. Our direct self-cooling technology eliminates the need for coolant liquids and slashes energy consumption by over 50%. Get the breakthrough you deserve with your rotary evaporator.




Creative Commons License
This work is licensed under a Creative Commons
Attribution 4.0 International License
.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.