No More Foo, Bar, and Baz

warrend

Daniel Warren

Posted on December 25, 2017

No More Foo, Bar, and Baz

When I was a kid, my best friend’s dad owned a computer company and told us he knew the secret to Fubar. He said he was sworn to secrecy and to this day has never divulged the secret. If you’re not familiar with Fubar, he was a 1980s robot whose name stood for Futuristic Uranium Bio-Atomic Robot. He seemed so life-like and I dreamed of owning one as a kid. Of course, now that I look back at old Fubar videos, it’s pretty clear Fubar was nothing but a big remote control car with a walkie-talkie strapped to his head, probably operated by a guy in a nearby room.

This brings me to my next point. Maybe they’re not related, but I’d like to talk about the use of “foo, bar, baz” in coding tutorials. I’m not quite sure if foo/bar/baz comes from Fubar, but they sound similar enough to make my point.

For those of you who write tutorials, you do such great work and we are appreciative. Without tutorials, the world of coders would be lost. But, for the love of God, please stop using foo, bar, and baz in your tutorials.

Unfortunately this disease has reached epidemic proportions. I recently ran into a tutorial where the writer explained the concept of associations in ActiveRecord using a similar example to below (I’m code-paraphrasing here):

class Foo < ActiveRecord::Base
  has_many :bazzes
  has_many :bars, through: :bazzes
end 

class Bar < ActiveRecord::Base
  has_many :bazzes
  has_many :foos, through: buzzes
end 

class Baz < ActiveRecord::Base
  belongs_to :foo
  belongs_to :bar
end 
Enter fullscreen mode Exit fullscreen mode

First of all, what the hell is a foo and a baz? We know what a bar is but are we talking about a bar/pub or a parallel bar? And how does it relate to a foo? In what capacity does a foo have many bazzes? For me, so many of these concepts take time to grasp, but make it almost impossible when the examples don’t have concrete meaning grounded in reality. Tutorial writers are much better off using real world examples, like how a tweet belongs to a user, or how a dog has many bones.

So please, keep writing tutorials, but do not use foo, bar, or baz!

💖 💪 🙅 🚩
warrend
Daniel Warren

Posted on December 25, 2017

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

No More Foo, Bar, and Baz
tutorials No More Foo, Bar, and Baz

December 25, 2017