The Power of 'foo_*': The Art of Balancing Flow and Clarity when Naming Things
Software Engineering Manager at Measurabl
Naming Things: An Incremental Approach
"Naming things is challenging, but with an incremental naming method, you can strike a balance between maintaining flow and ensuring code quality."
When writing code, finding the right names for variables, functions, and classes can be a difficult task. It's important to maintain your flow while also ensuring that your code remains readable and maintainable in the long run. In this article, we will explore a practical approach to tackling this challenge – an incremental naming method.
Problems With Names
"It's easy to get bogged down by trying to find the perfect name from the start. This will disrupt your coding flow and hinder progress."
The challenge of naming components can often disrupt your coding flow and hinder progress. Spending too much time trying to find the perfect name from the start can be counterproductive. To overcome this challenge, we need a method that allows us to focus on functionality while delaying larger implementation decisions for later.
Solution: The "foo_*" Method
"Instead of striving for perfection upfront, embrace an incremental naming method."
Instead of striving for perfection upfront, we can embrace an incremental naming method. This method involves giving components temporary functional names like "foo_payment" or "foo_processing." These names act as placeholders, allowing you to stay in the flow of coding without getting caught up in naming decisions. The key is to focus on functionality, get your code up and running, and maintain your momentum.
Transitioning To Meaningful Names
"As your codebase takes shape, you'll naturally gain a deeper understanding of the system's architecture and components."
As your codebase takes shape, you will naturally gain a deeper understanding of the system's architecture and components. At this stage, it's important to transition from temporary names to meaningful names. To guide this transition, ask yourself key questions about the core purpose of the component, how it fits into the overall system, and whether the current name is descriptive enough for someone encountering it for the first time.
The Benefits of Incremental Naming
"One of my favorite parts of an incremental naming strategy is that these temporary names serve as indicators when refactoring."
One of the benefits of an incremental naming strategy is that the temporary names you initially give to components serve as indicators when refactoring. When you revisit your code after a mental break, these temporary names can trigger a holistic view of the codebase. Performing a global search for "foo_" at this stage can help you identify areas where code sections could be streamlined, merged, or where more detailed documentation is required.
"The goal is not to let the pursuit of perfection hinder progress – 'Good Enough' in the moment can lead to 'Great' in the long run."
Naming things is a challenging task, but with an incremental naming method, you can strike a balance between maintaining flow and ensuring code quality. By starting with functional temporary names, you can keep your momentum and creativity intact. As your understanding of the system deepens, transitioning to meaningful names becomes a natural process, enhancing code readability and collaboration. Remember, the goal is not to pursue perfection from the start, but to achieve greatness in the long run by focusing on what is "Good Enough" in the moment.
Connect and Learn with the Best Eng Leaders
We will send you a weekly newsletter with new mentors, circles, peer groups, content, webinars,bounties and free events.