by devishard · 10y ago · 0 comments
# Map from user ID to User object.
userIdMap = {}
Or as I would write this: userIdsToUserObjects = {}
Ctrl + n in vim completes this easily, so I don't care how long the name is.I agree about the general point of the article, being strong in one language, but poor naming will bite you in any language. Comments are apologies for bad code: only write comments when you can't write better code.
messagesByUser = {}
Is the key a user id, username, a user object, some sort of stripped down user hash, what? What about the messages? If you try to cram all this information into the variable name then you've invented a perverse form of hungarian notation. And of course you lose all that precious type information every time you pass it off to a function.Python is my go-to crutch for quickie projects that will never grow beyond a few hundred lines of code. Anything more complicated needs a typechecker. I only wish Java's was more robust.