Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
but foo bar are THE designated example variable names.
do you want us to not use `i` in for-loops as well? -
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) -
cygnus11293y@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. -
@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
-
cygnus11293y@NotJeckel ok it's just an example. Wait till you see some devs prefixing their variable names with var or int or whatever 😏
-
@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.
-
@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 😎 -
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'
STOP USING FOO BAR IN YOUR GODDAMN EXAMPLES. I BEG OF YOU.
rant