The Quest of Writing Beautiful Code

Photo by Charles 🇵🇭 on Unsplash

F#!k this. I find myself saying every time my code doesn’t compile or my unit tests don’t pass. Segmentation Fault. Not all expectations were satisfied. Why the flip Im I doing this?

Why Im I spending hours and hours on some mumble jumble piece of text that makes me want to pull my hair out? I’ve spend more time on Stack Overflow than I spend sleeping damnit.

Well, If I was done with everything, you know, the usual, “Oh thank god it works!” (Even if you don’t believe in a god, trust me when you go down the dark path of coding, you’re gonna need one) I’d be writing this blog post pretty chill, drinking a cup of tea and everything. BUT IM NOT. Im still in the mess of nothing-working-don’t-know-why. Time is running out as I need deliverables. Concrete evidence of a big-chunk of“HEY LOOK I WROTE SOMETHING IT WORKS PLEASE GIVE ME A GOOD MARK.”

Okay about an hour has passed and still, nothing works. I’ll be honest here, excuse my rand before, I love coding. How you turn letters, words and symbols into an application that helps you achieve things that help people with their lives in weird, different, miraculous sort of ways. Yet, now anyone can code, go online, search for a course and voillá after 2–3 hours you can write a simple “Hello World!” program. Congratulations.

Well, things are not that easy. As I get older, and surprisingly more mature, I begin to understand that writing code that just works is not enough. It’s probably enough if you are doing it for assignments (speaking for myself as well) but not for writing robust, scalable and/or secure applications.

…writing code that just works is not enough.

Currently Im doing a Software Engineering module at University, which, its coursework involves working with a legacy codebase, refactoring it and writing Unit and Integration tests. Through this module, I’ve come to realise that writing code by following design-patterns, common practices and specific architectures not only makes your code more maintainable but it also makes your whole coding experience much more structured. Hence, when you write code you must make the experience as structured as possible and the reason is, through a structure comes efficiency. And efficiency saves you both time and if you are lucky enough, money.

Some tips, from my experience would be to read some books about Object-Oriented Design principles and patterns, see how production code is written, explore how code is deployed to production. Don’t be afraid to experiment, don’t focus only on the finished product, don’t focus only if it works. Focus on writing beautiful code.