5
cygnus
2y

STOP USING FOO BAR IN YOUR GODDAMN EXAMPLES. I BEG OF YOU.

Comments
  • 8
    Why ?
  • 9
    but foo bar are THE designated example variable names.

    do you want us to not use `i` in for-loops as well?
  • 11
    Fine I'll just start using

    Class Fizz{
    func Buzz{
    }
    }

    Everywhere instead.
  • 7
    it's like

    Batman and Robin (and the asshole Jocker)
    Love and Marriage (and kids)
    Bonnie and Clyde (and police chasing them)
    + and - (and the undecisive 0)
    Alice and Bob (and that Mallory bitch)

    You can't separate them. You just... can't. It will always be

    Foo and Bar (and that Baz imbecile)
  • 2
    @tosensei I dunno man. using i as a loop variable looks ok coz everybody knows its a loop index. But using Foo bar instead of specific names makes it difficult to understand the context.
    class Animal {}
    class Dog extends Animal {}
    class Cat extends Animal {}

    var foo = new Dog()
    var bar = new Cat()

    var myDog = new Dog()
    var myCat = new Cat()

    myDog.bark() and myCat.meow() is way easier to understand than foo.bark() and bar.meow().

    Especially when someone else is looking at your code. In the latter case you need to go to the definition of the variable to understand the context.

    This is an oversimplification but you get my point.
  • 1
    @cygnus I guess they're trying to make their explanations context free (ha), but I agree that just providing a couple of contexts helps give off a weird message
  • 3
    Foo and bar are better than prefixing variable names with "my".
  • 4
    Okay, "boo far" from now on.
  • 1
    @NotJeckel ok it's just an example. Wait till you see some devs prefixing their variable names with var or int or whatever 😏
  • 3
    @cygnus well, that's just an example of misusing it. metasyntactic variables are used when it explicitly _doesn't matter_ what those variables are. i'd argue that "what those variables are" is the most important part of inheritance.
  • 1
    @cygnus Prefixing variable names with their type hails from days yonder when your average IDE was a more or less dumb text editor. It's called hungarian notation if I remember correctly. Made it a hell of a lot easier to tell what type you worked with.

    Take a look at some old MS C++ examples of creating windows and you'll find pointers to window objects which start with hwnd, like hwndSomeWindow. I.e. handle for window XYZ.

    Fair enough, today that might not be needed, and might be used in a misunderstood way... Or just as plain fuckery 😎
  • 0
    I'd rather have a real example instead of nonsensical placeholders. Programming languages follow certain grammatic rules and it's easier to understand functions as verbs and variables as subjectives.

    @cygnus If 'foo = new Dog()' I'd rather use 'rex' instead of 'foo'
Add Comment