- nerd_splash
- Posts
- Legacy code, binary search, and naming conventions
Legacy code, binary search, and naming conventions
Hi nerds -
I salute you from sunny Madrid, where everyone keeps talking about their upcoming vacation plans.
Today I'll do things a lil bit different and share with you some of my insights combining coding and mindfulness. Let me know what you think. 👩🏻💻
Madrid, España
3 brain farts
👵🏻 Legacy code: Legacy code is old code that contains no tests and quickly grows impossible to understand. It's a disease to a large codebase because it compounds in complexity and makes the entire application harder to maintain and scale.
If left unsupervised, it grows so large, organizations crash because the cost of rebuilding the software is too big and the speed to produce new features becomes too slow.
Our personal legacy code are those assumptions and building blocks we live by, which we don't test and no longer understand. It's the lil rules we follow and take for granted; the habits that no longer serve our path; the "emotional baggage" we carry everyday.
If left unsupervised, it piles up, increasing the cost of self-awareness and building an identity that is harder to maintain and scale.
🔎 Binary Search: Our brains don’t have a storage problem, they have a retrieval problem. Everything we’ve ever experienced, thought, or said exists somewhere within our mind, but finding it is often the harder part.
A similar thing happens in Computer Science, where databases grow so large, finding relevant information efficiently becomes complex and time-consuming.
One of the most performant algorithms we have to find information is binary search. It works as follows:
The data pool must be sorted using some sort of logic. For ex, you can arrange your experiences by date, by feeling (happiest to saddest), alphabetically, etc.
Once you have the information sorted, you split the list in two and ask yourself: “on which half would the information I’m looking for be?” If you’re looking for Bob’s number, for example, you’ll know it’ll be on the first half of the alphabet-sorted list because it starts with a “B”.
Then, repeat this process splitting your data in half until you find the information you’re looking for.
This is super powerful because it means we’re cutting our possibilities by half as we traverse through the list, rather than exponentially increasing the number of operations we have to run.
-- For your reference, binary search is O(log n). O(i), meaning constant time, is the best, while Big O notation is the worst.
💙 Naming conventions: When naming variables or functions, developers may feel tempted to use short names like “a” or “x”.
In theory, the code will work the same, but next time we want to build a new feature on top of it, developers will have a harder time understanding what the code is meant to do, ergo a harder time providing a good solution.
A similar thing happens with our emotions. When describing thoughts and feelings, we often use words like “happy” or “angry”. However, we can usually do better.
Naming feelings is key to emotional intelligence and self-awareness because we handle situations better when we understand exactly what they are. Here’s a cool cheat sheet on naming emotions.
--- 👀 If you want to learn more about writing clean code, I wrote an article about the topic here.
2 intellectual goodies
"There are two methods in software design:
1) One is to make the program so simple, there are obviously no errors.
2) The other is to make it so complicated, there are no obvious errors."
~ Tony Hoare
"It's hardware that makes a machine fast. It's software that makes a fast machine slow."
~ Craig Bruce
1 funky audio
This song is for the saxophone lovers. You know who you are. 🎷
Thanks for reading.
As always, feel free to connect by hitting reply and sharing a juicy thought 💡.
We all help the curious community grow.
Best,
Jules 🤸🏻♂️
Reply