As a beginner developer, I was always confused as to why others would use foo, bar, or baz. When I approached these words used in examples I assumed that they were pertinent to the code I was reading. I quickly learned that these names did not hold any weight and were often used in teaching examples as a placeholder for a better name.
While learning how to program, I've both picked up and discovered my own naming conventions. I've found that taking an extra moment to think up a clear name has been better for my understanding of the code presented, my peers reading my code, and future me, who doesn't vaguely remember what said code does.
Let's look at an example using foo/bar/baz:
How can this be improved for future programmers to read? If I take an extra moment to rename the variables then the function becomes easier to understand because each variable is pertinent to its data.
This is definitely a basic example, but all programmers start somewhere. I believe that naming examples with words or phrases can:
- Help a person grasp a concept more easily when learning to program
- Begin to teach them how to name data clearly
- Create a better programmer from the start
Thanks for hearing me out. If you're interested, here's a cool Stackoverflow post about foo/bar/baz's history.