The Art of Adaptable Code
Tags: programming, development, beginners, softwareengineering
Published: 2023-07-03 11:33:49

In the ever-evolving world of software development, there's a principle that's often overlooked. It's not about writing the perfect code, but rather about writing code that's easy to change. Yes, you read that right. The goal is not to write 'correct' code, but to write code that's adaptable, flexible, and ready to evolve with the changing tides of reality. 

## The Illusion of 'Correct' Code

The first thing we need to understand is that all code is, in essence, incorrect. Why? Because code is a model of reality, and reality is always changing. So, the code you write today, no matter how 'correct' it may seem, will eventually become outdated as the reality it models evolves. 

Take, for example, the Goods and Services Tax (GST) in Australia. The rate of GST has remained the same for over 20 years, but the rules for applying it have changed numerous times. If you had hardcoded the rate into your program, you'd have to rewrite it every time the rules changed. But if you wrote a function that calculates GST, you could easily adapt it to the changing rules. 

## The Power of Change

Many of the practices and design principles we follow in software development, such as DRY (Don't Repeat Yourself) and SRP (Single Responsibility Principle), are essentially about making code easier to change. Even the entire Agile movement is about making it easier to change the product being produced. 

But how do we know which path will make future change easier? This is where intuition comes into play. 

## Trusting Your Intuition

Intuition, developed through experience, guides our decision-making process. It's not about knowing the future, but about having a gut feeling about what's going to be easier to change. 

To develop this intuition, try this method: before making a change to the code, write down a one-sentence summary of the change and an estimate of the effort it will take. After making the change, write down the actual effort it took and any observations. This process helps to train your subconscious mind. 

Remember to verbalize these thoughts, as it strengthens the reinforcement of the learning process. 

## Embrace the Change

In conclusion, the art of writing adaptable code is about embracing change. It's about trusting your intuition and making coding fun. It's about acknowledging that our code will never be 'correct', but it can always be adaptable. 

So, the next time you sit down to code, remember this principle. Don't strive for 'correct' code; strive for code that's easy to change. 

For a deeper dive into this topic, check out this insightful [video](https://youtu.be/QvK3Pxmwcyc) that inspired this post. It's a thought-provoking exploration of the art of adaptable code that will surely change the way you approach your next coding project.

So, what do you think? Have you been focusing too much on writing 'correct' code and not enough on writing adaptable code? Share your thoughts and experiences in the comments below. Let's start a conversation about how we can make our code more adaptable and our coding process more enjoyable.