3 ms·
There's an interesting question that arises when you says "when you alphabetize them place related variables next to each other". Let's say you have some non-t
by mankyd 4y ago
There's an interesting question that arises when you says "when you alphabetize them place related variables next to each other".
Let's say you have some non-trivial class that includes, among others, some 2d rectangular data: An x, y, width, and height. They're all related, but they don't naturallly occur near each other without a little massaging:
coordX, coordY, sizeWidth, sizeHeight?
xMin, xMax, yMin, yMax?
coordXMin, coordXMax, coordYMin, coordYMax?
I generally agree with your sentiment, but there's a reason "naming things" is one of the hardest problems in computer science :)
- saghm 4y agoI'm not quite able to verbalize exactly why, but when I see the set of { "coord", "x", "min" }, it sounds to me like the most intuitive way to put it would be "x_coord_min", but this seems to violate the rule that GP gave, since "coord" here seems to be "greater" than "x" given that "x" is an answer to "what kind of coordinate?". The best explanation I can come up with is that "x coordinate" feels like a coherent logical unit and that splitting it would make it more work for me to parse as a reader, and then "min" follows that because "min_x_coord" sounds like it would be something like the "minimum x coordinate" for a given window or something. I wish I could come up with some consistent universal rule for how to order these things, but I can't really come up with any other process to describe how to get what's the most intuitive other than "look at all of them and see what sounds right". I guess it's not unreasonable to say that ordering three "words" is fairly easy to brute force looking at all of them, and beyond that it's probably worth reconsidering the naming (and perhaps scoping) of the variables you need to disambiguate, but it's not nearly as satisfying as having some sort of objective rule.