Legacy code, binary search, and naming conventions

publishedabout 2 years ago
2 min read

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. ๐Ÿ‘ฉ๐Ÿปโ€๐Ÿ’ป

Calle de Fuencarral, Madrid


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.

Working that legacy code


๐Ÿ”Ž 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:

  1. 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.
  2. 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โ€.
  3. 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.

Algorithmic performance graph


๐Ÿ’™ 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

Computer errors


"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.



Jules ๐Ÿคธ๐Ÿปโ€โ™‚๏ธ


Learning to code is 21st century super-power. I work as a Software Engineer and teacher around the world. My purpose is to empower others by showing them what we can do with our brain, a computer and wifi.

Read more from juliette_chevalier

Matrix, angels, and amateurs

about 1 year ago
โ€ข2 min read

Social engineering and internet friends

about 1 year ago
โ€ข1 min read