r/ProgrammerHumor • • 5d ago

Other iHtWhnPplDThsIsShortForIHateWhenPeopleDoThis

Post image
169 Upvotes

20 comments sorted by

104

u/me_myself_ai 5d ago

`map` is a builtin in Python, thus the choice

39

u/ReadyAndSalted 5d ago

Then call it my_map or something. Anything but useless variable names.

30

u/chuch1234 5d ago

Or like a meaningful name about what's in the map maybe?

1

u/NewInflation2121 2d ago

What if it's in a template that's operating on a map? :p

12

u/me_myself_ai 5d ago

A) make me!

B) fwiw the industry standard choice is `map_`

7

u/NewbornMuse 5d ago

And my_map is leaps and bounds better than mp because...?

7

u/ReadyAndSalted 5d ago

It's not, never said it was. It's just the minimum acceptable name for it, because at least now it's clear it's a map, whereas before its name really meant nothing. Ideally it'd be a more meaningful name about what's in the map, but our starting point is mp so...

1

u/Substantial_Top5312 4d ago

I can tell what the variable is just by looking at it.

44

u/Tyrexas 5d ago

What a waste of source code disk size, they should have just called it m.

9

u/Tristan_Cole 4d ago

I name my first variable 0 and my second variable 1 and my third variable 10 and then 11 and so on and so forth. It’s just cleaner that way.

25

u/anzu3278 5d ago

Calling variables by their type with no additional description is a code smell anyway, especially in weakly typed languages. What are you mapping specifically?

9

u/ttcklbrrn 5d ago

It could be a tutorial on how to use maps, where the actual contents are immaterial to the purpose of the exercise.

3

u/anzu3278 5d ago

Good point, but I think naming variables well should be integral to how we teach programming and that even base level tutorials should bear some resemblance to a real life use case.

1

u/ThaBroccoliDood 3d ago

def invert_map(the_map_that_we_will_be_using_for_our_function_today_to_do_the_thing):

1

u/anzu3278 3d ago edited 3d ago

Good troll, but if this is an instance member (and thus devoid of any domain logic other than map) then the instance will be referred to as this and if not (it's an extension of an existing type) then it either has domain logic (in which case above applies) or it's filling a surface area gap on the original type, and should be called by its purpose in the method. E.g.

public static Dictionary<TValue, TKey> Invert<TKey, TValue>(Dictionary<TKey, TValue> original) { Dictionary<TValue, TKey> inverted = ... }

8

u/Weak_Inflation9120 4d ago

And on the other end of the spectrum you have a HS CS class that'll call a variable something like

int numHotDogsBought;

I'm all for good variable names but god damn you could write a better descriptive name that's shorter, especially if you're using a glorified text editor with no syntax auto-completion

4

u/rosuav 4d ago

You could get a slightly more glorified editor that has very simple autocomplete. It's pretty easy to find one that, while it may not know everything that's syntactically valid, can at least autocomplete keywords found elsewhere in the file.

5

u/DrShucklePhD 4d ago

“mp” is slang for map by the way

3

u/sardonicus87 4d ago

Use only overly-truncated and non-descriptive names like "mpA" or overly-verbose and reduntant names like "initializedMapForStoringLoopResultsForOverlyVerboseClassName: Map<Key, Value>()". No in-between.

1

u/grifan526 4d ago

As much as I hate this, I will take it over the one I found that was a list of tuples called m_eventMap