3 ms·
> I'm sure a lot of people have this problem: naming things. Can't code until you figure out what that variable should be called. i, j, k, foo, bar, baz, and d
by hansvm 6y ago
> I'm sure a lot of people have this problem: naming things. Can't code until you figure out what that variable should be called.
i, j, k, foo, bar, baz, and don't waste a moment thinking about it till your solution is finished and warrants a once-over (or till it has grown sufficiently complicated that a real name is finally necessary even if temporary -- try to work in small enough units that this never happens).
- vageli 6y agoThis reminds me of advice I learned in school for writing: if you are having trouble coming up with an introduction, just write as if you already introduced the topic and come back to the intro afterward.
- 8note 6y agoI generally think that if I can't find a good name for a thing, I don't actually know what it does yet, so Im not ready to code it. I, j, and k have clear definitions as basis vectors, so they can be used, but I don't think I'd ever call a variable foo or bar
- amelius 6y agoUse an APL keyboard and you'll have more options. https://geekhack.org/index.php?topic=95872.0 https://geekhack.org/index.php?topic=95872.0 I do think we need a modern hacking keyboard though.
- PopGreene 6y ago(I know this is going to date me.) I used APL before and during college on a terminal with a type ball. (https://en.wikipedia.org/wiki/IBM_2741 https://en.wikipedia.org/wiki/IBM_2741) APL is a great language.
- hansvm 6y ago> I generally think that if I can't find a good name for a thing, I don't actually know what it does yet, so Im not ready to code it. I can understand that viewpoint. On the other hand, you have to develop that understanding somewhere, and on some problems I find that sketching out a solution in code is more productive than using a whiteboard or some other mechanism, especially if I already have a rough idea of what needs to happen. E.g., I might know that I need to keep around a little intermediate state, and I'll throw that in an unremarkably named variable and iteratively build up the rest of the algorithm. Once I have _some_ solution I can go back and see if the variable was really important, prove it correct (or find additional work to do), and dole out meaningful names. The idea isn't that different from how when building up something which needs a loop you might start with "while (True) {}", figure out where you need to break, and then go back and factor in an appropriate stopping condition once you understand exactly what the loop needs to do to accomplish your goals.
- tpxl 6y agoJust use Java, then your FooClassFactory instance can just be named fooClassFactory :)
- deleted 6y ago[deleted]