Foo, Bar, and Baz: Not Having It
linguapragma.com
linguapragma.com
I'm not entirely sure if the author uses "language documentation" as synonymous to implementation semantics, like OO. The above was written assuming he isn't, because in my mind OO is a concept largely unrelated to the underlying programming language.
If he doesn't, then priming the brain with a set of well-known entities or concepts and how they relate to each other and then mapping them to the material you are trying to teach is desired. But, there is a balance to be struck between abstract reasoning and tying abstract patterns to things such as a cat or 'mew'.
Are foo, bar and baz understandable terminology people can relate to like dog and bark? Not always. But if you don't speak English, dog and bark may make the same amount of sense as foo and bar.
I use them frequently in one-off programs that are destined to be thrown away in a day, but never in code I share. They are, at least in my mind, markers of badly thought out code (so badly thought out that I didn't spend the time necessary to think up good variable names!).
Posted on April 21, 2012 These placeholder variables are the worst thing to happen to language documentation in the modern era. And so there’ll be none of this on Lingua Pragma. I’ll illustrate the problem by demonstrating classes in ruby. Compare:
Example 1
class Dog def speak return 'woof' end end
class Dachshund < Dog end
fido = Dachshund.new fido.speak => 'woof' Example 2
class Foo def bar return 123 end end
class Baz < Foo end
qux = Baz.new qux.bar => 123 Which example conveys more information? Which is easier to quickly grasp? Which would you rather read?
The dog motif in Example 1 came to me because my GF asked me to write an app to simulate a pet salon. And I’d model the classes something like this.
(alternate link: http://webcache.googleusercontent.com/search?sugexp=chrome,m...)
Example 1
class Dog def speak return 'woof' end end
class Dachshund < Dog end
fido = Dachshund.new fido.speak => 'woof' Example 2
class Foo def bar return 123 end end
class Baz < Foo end
qux = Baz.new qux.bar => 123 Which example conveys more information? Which is easier to quickly grasp? Which would you rather read?