Dec 22, 2021 12:00:00 AM •
Author: Richard M. Naber
The power of simplicity.
It was one of the most remarkable discoveries, back in the 17th century. Of course, everyone knew that apples fell down. And of course, the Moon and planets moved through the sky without falling down. But explaining both of these observations, apparently so unrelated, even alien to each other, with a single force? That is brilliant. Genius, even.
With the discovery of the Law of Gravity, Isaac Newton succeeded to describe and predict all kinds of observations in a single equation. Suddenly the orbital complexity of the solar system was reduced to the simplicity of a few strokes of a pencil.
But it got even better. In the centuries thereafter, it was discovered that all actions in nature, from within atomic nuclei to large-scale galaxy clusters, could be described with just four fundamental forces. And scientists are working hard to combine everything into a single theory: the Theory of Everything. This simplicity resembles the simple coding examples in textbooks of software development.
Most complex structures in the universe
Almost two centuries after Newton published his Principia Mathematica, another groundbreaking study was published, with the name "On the Origin of Species". In this book, Charles Darwin revealed the secret of evolution by natural selection. The principle led to the conclusion that our bodies evolved from simpler animals, and ultimately from protozoa. The blueprint of the animals, the DNA, is passed on from generation to generation, with some random mutations that might increase the chance of survival. The environment (and some luck) determine the specs for which these mutations might be beneficial. The result: extremely complex organisms such as you and I. Our brains alone are the most complex structures known in the universe. This resembles the complex functionality of the applications we sometimes ought to build. This is in sharp contrast with the simplicity of the laws of physics, even though everything involved in evolution is based upon these laws.
One long, poorly optimized line of code
Functionally, our bodies are quite a success. We are adapted to such extend that we are potentially capable to create towers, go to the moon, and even do kitesurfing. Physiologically, our bodies are a mess: our bipedalism regularly results in back problems, a human foot contains seven bones stuck together whereas it could equally well be one bigger bone, and our brains are not clearly compartmentalized: several functions are all over the place. This is what you get when you compile a body based on your DNA.
But honestly, no developer cares what a compiled application looks like. What we care about, is what the underlying code looks like. Bad news. Our genes are also a mess. Consider the so-called Ognan gene. Throughout our DNA, we have several non-functional copies of this gene. Random copies that did not result in any benefit, but also not in any disadvantage, so they kept on being copied. We also have a chromosome that is a merger of two original chromosomes, still present in apes. It looks like these genes are simply glued together, head to tail. All in all, our genetic code is a mess. It is full of legacy. 60% of your DNA is the same as that of a banana. This is why genetics is so hard: it is nearly impossible to understand the code.
Now this resembles the code that developers are sometimes confronted with. In the books, it always looks clean and simple like the laws of nature, but the reality is far more unruly.
Leave it better than you found it
As the environment changes over time, directing evolution, so do the specs that determine the functionality of an application. This leads to changes that often increase the complexity of the code. If we would simply allow for the evolutionary growth of an application, it would become unreadable, unmaintainable, leading to severe errors.
As developers, we attempt to prevent this by using two rules:
Never write quick and dirty code
The boy scout rule: leave the code better than you found it.
But this is not enough. Many changes on a small scale can eventually make code unreadable or unmaintainable on a larger scale. This is when refactoring comes into the picture. This is also where the customer or product owner will be asked for time to allow this. If you are a product owner, say wholeheartedly "Yes" to refactoring, even if it means other functionality will have to wait. Refactoring improves the design of software, makes software easier to understand, helps to find bugs, and helps in executing the program faster. It makes new functionality easier to implement and will definitely reduce costs in the medium term.
This is what makes the difference between developers and Nature: evolution is an unguided process, where there is no opportunity to interfere and make the DNA beautiful. In writing code, we do have that opportunity. Use it, whenever you can. An application will never be so simple as the four fundamental forces, but nonetheless, we should always strive for it, like the scientists that strive for discovering the Theory of Everything. Code is no place for natural selection, let there be evolution by unnatural refactoring!
Ready for evolution?
Do you want to find out more about how our team can help you with your software engineering challenges? Feel free to reach out!
Richard M. Naber Kotlin Lead Developer & Scientific Analyst
Ready to Transform your Business with Little Effort Using Vertical?