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
-
C0D4669023yI usually make a long ass Boolean a single var before dropping it into the if(), just so the if() isn't 10 lines long, but beyond that ..... nope.
-
sariel84473yI worked with a dev that would make vars for everything.
Looking up records from the DB just to loop through them? Var it, loop it, move on never to use it again.
Code needs to perm check? Better make a var for the user, the permissions, and the bool value if they have the perm.
I asked them why they kept making useless vars and I shit you not, they said, "because whoever has to come back to the code later won't know how it works unless the vars are there."
I stared blankly at them and told them to use comments if the logic is *that* complex. -
ltlian21883yI worked on a project where this was done a lot. var result = arg0 + arg1; return result;
The reason was that it was easier to debug because then you could use breakpoints and look at the intermediate results.
I don't think that was a very good reason. -
sariel84473y@ltlian I haven't used breakpoints in almost a decade.
It was also the last time I did .net development too -
When i program for a microcontroller: Almost never, there are only downsides and it consumes more memory.
For software on a hosted environment, i mostly use pointers and copy when i do things like calling functions that change the object but i still need the original or when i only made a functions that take a format string, similar to printf(), which make a copy even when i have no format specifier.
What i sometimes do is copy a pointer variable to make code shorter, but not sure if that counts because the compiler can optimize it away.
do you guys make a temp copy of every single object and/or variable you ever use? ive gone thru a few projects in this company and our code has so much of this. I cant remember now if there is even a good reason to do it like that. you can end up with a lot of copies! haha!
rant