Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
@hardfault
I never call anything tmp.
Counters are trditionally called "i", "ii", or "iii" (but if there are three nested for loops you probably need to refactor that shit).
Temporary collections are most often "parts".
Temporary natural numbers are "n" or "m".
Coordinates are "x", "y", or "z".
But naming something "tmp" is a sure sign that you actually don't know, what it is (not only speaking of the data type). -
matt-jd10095y@Oktokolo I think it's perfectly fine to use tmp for certain things like a function that performs some trivial manipulation of a data structure and needs to store something temporarily
-
@Oktokolo tmp is perfectly fine if it's use is obvious. That means your function is so small that you can obviously see what it is.
-
ltlian21885ytmp is fine if it's obvious in the context. I would fire you the moment you start using tmp2 and higher in the same scope.
-
As a rule of thumb, for all inobvious/meaningless names (like tmp) I should be able to position the viewport such that all uses of the variable are included and every other visible name makes sense.
-
@electrineer
Yes, it would be tolerable in the really obvious cases. But i never had giving a proper name leading to code becoming less obvious. And if you understand what the code does (wich an obvious cases implies), better names come into mind automatically.
So i still would advice against using "tmp".
Related Rants
I am writing a UI api for microcontrollers as a pet project.
I usually follow kernel.org for coding style so visited the site to see if there are any changes, these docs are so funny
rant
coding style
kernel