4 ms·
His variable names really bother me. I can live with "lat", "lon" if I must, but "d", "md", "trkpts"? Readability would be greatly enhanced if he just spelled t
by compostor42 11y ago
His variable names really bother me. I can live with "lat", "lon" if I must, but "d", "md", "trkpts"? Readability would be greatly enhanced if he just spelled those out.
Programmers shouldn't be wasting brain power deciphering cryptic variable names. Save that energy for where it counts (solving actual problems!)
- deleted 11y ago[deleted]
- mondoshawan 11y agoThe fact that you're guessing is the parent's point. Code should be explicit.
- deleted 11y ago[deleted]
- compostor42 11y ago"Not crazy" is a low standard. The point is I shouldn't have had to exert any mental energy whatsoever to understand what those variable names represented.
- GFK_of_xmaspast 11y agoIf you're exerting more than a trivial amount of mental energy to figure out those names then you simply need more practice.
- compostor42 11y agoThe point is, I shouldn't need to exert any mental energy at all. Code is read more than it is written. The onus is on the author to make things clear. The example provided is trivial, sure. As complexity increases and you have more cryptic variable names to juggle, you'll be glad for the explicit, clear names. Also, keep it mind that code will need to be comprehended in less than ideal circumstances. The engineer getting woken up in the middle of the night to fix a bug in production will not be at their mental peak. They'll be grateful for the clear naming conventions.
- taeric 11y agoMeh... the idea that you can boost some brain power by relaxing other tasks seems unproven. I will go so far as to say all of the truly buggy software I have ever seen had the most explicit variables. To the point that it is just a sideshow. Use them if they don't get in the way. Don't if they do.
- collyw 11y agoThe most unmaintainable code that I have had to refactor had crappy variable names. It worked (until the database interface changed) though.
- gregor7777 11y agoGotta say I agree with this. I notice a lot of Python programmers tend to use less descriptive variable names. That's always been a pet-peeve of mine.
- JupiterMoon 11y agoSource?
- asdfas123414 11y agoHimself. "I notice a lot of Python programmers tend to use less descriptive variable names."
- shele 11y agoLovely :-)
- bliti 11y agoI've found that sometimes its due to the programmer not wanting to try and figure out a good name for the variable. It sounds like a simple problem, but it is actually quite hard! Good variable names provide meaningful context that improve readability.
- chaosphere2112 11y agoTo be fair, this has the scent of a one-off script to do some simple analysis, versus something that's going to live in a git repo for the rest of eternity. In the project I work on, I found a wonderful rats nest of variable names in a function that led to an excellent bug where "N" and "n" were swapped, leading to a completely different result.
- TickleSteve 11y agoNaming is one of THE difficult problems in software development, once you have the name decided, the functionality can be determined from that. Poorly named functions/modules/variables/classes, etc are indicative of poorly thought out code.... as the other subject of this post (c vs python) also confirms.
- falcolas 11y agoI think he explained that quite adequately - he's writing C in Python. In C, such short names are fairly common. You will see similar naming idiosyncrasies if someone writes Java in Python, or lisp in python (or Python in C, or Java in Lisp, etc.).
- TickleSteve 11y agoI would completely disagree with that. no excuse for names like that regardless of language.
- falcolas 11y agoNot that I necessarily agree, but here's what K&R has to say on naming variables: "A variable or function name should be sufficient to understand the meaning, while remaining concise. The shorter the lifespan or scope of a variable, the shorter its name should be; conversely, the more important a variable, and the more places it is used, the more descriptive that name should be." These names certainly conform to this standard.