Coding with Quality in Mind

The Four Essentials Great Software Engineers Consider

Introduction

In today's world, software is everywhere: in our cars, watches, phones, even on our toasters; and there's a lot of content online about becoming a software engineer, building apps, creating your next (million dollars) tech startup in a day, etc. but very little is said about writing quality code that can withstand the dynamic and complex environment that our modern applications live on today.

In this blog post, I want to introduce the 4 main attributes you should think about when building your next app.

Laying the Foundations

Imagine you're building a house. You'd want it to withstand storms, be capable of renovations, use materials that could be repurposed, and importantly ensure it keeps out unwanted guests.

Similarly, when we're coding our software, we must embed these qualities from the get-go. In other words, we want our software to be: robust, adaptable, reusable, and secure. This not only elevates our software's value, but ensure it can meet both current and unforseen challenges.

Robustness

All software engineers would agree that your code should be correct, meaning it produces the right output for all the expected inputs. But in addition to that, a great sotware engineer makes sure his/her software is robust.

Robustness in sofware is like a skyscraper's ability to sway with the wind without toppling over, or tolerate small earthquakes without tearing down. It's about handling the unexpected gracefully.

Imagine a function that processes user input for example. It should not only handle valid inputs, but also deal with the unexpected, ensuring the program doesn't crash and burn.

def process_integer_input(user_input):
    try:
        # Attempt to convert input to an integer
        processed = int(user_input)
        print(f"Input processed: {processed}")
    except ValueError:
        # Handle the case where input is not an integer
        print("Invalid input. Please enter a number.")

# Example usage
process_integer_input("42") # Valid input
process_integer_input("hello!") # Unexpected input

Next time you're writing a piece of code, think about how you can make it more robust. Test it for robustness (hopefully you are writing tests, right?), give it "weird" inputs and test how it handles them. This will ensure your code handles the unexpected gracefully.

Adaptability

Modern software applications are always subject to change: new requirements come in, modifications and new features, technology changes, etc.

Adaptability in software is akin to making renovations on your home; as your needs change, so too can the structure of your home. Your software should be designed with the future in mind, allowing for changes without a complete overhaul.

Be careful though, this doesn't mean all your code should be configurable or that you should think ahead of every future possible change. This means your code should be easy to change as new requirements arise.

Reusability

Have you heard of the term "Don't reinvent the wheel?". It may seem obvious but you'd be surprised how much code out there in production has repeated/similar logic all over the place in their codebase.

A great software engineer makes sure that his/her code is reusable. He/She ecapsulates the code into modules of closely related functions and classes that are logically grouped together so they could be used as a component of different systems.

To illustrate this with an example, image you're working on a real estate app with a business requirement to present the "price per square foot" everytime a user goes into a real estate listing. You could re-write this on every place where your code needs it or you could wrap it up in a function:

def calculate_price_sqrft(market_value, depreciation_rate, square_ft):
    return (market_value * depreciation_rate) / square_ft

# This function can be used in any component that needs to calculate the price per square footage
print(calculate_price_sqrft(500000, 0.05, 2687)

Security

A great software engineer knows that security shouldn't be an afterthought. He/She knows that in today's modern world of cloud applications, it's imperative that she does everything within her abilities to protect the user's data from bad actors.

Security measures must be ingrained in the software's design to safeguard against threats. Think about this proactively when you're building your software. Ask yourself should I encrypt my database at rest? Should I handle Identity and Access management or can I use a secure, proven service like AWS cognito or Auth0 to do it for me?

Conclusion

There are many things we could be taking into consideration while building a software application. A great software engineer keeps these 4 goals top of mind from the get-go: robustness, adaptability, reusability, and security.

By embedding these into the very fabric of our software, we save ourselves from trouble and wasted resources in the future.