4

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!

Comments
  • 5
    I 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.
  • 4
    I do when I am getting paid by line of code, and memory consumed.
  • 2
    I 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.
  • 2
    I 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.
  • 2
    @ltlian I haven't used breakpoints in almost a decade.

    It was also the last time I did .net development too
  • 2
    @sariel Good luck debugging code for embedded controllers without breakpoints.
  • 1
    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.
  • 1
    @happygimp0 I don't know what you're talking about.

    My code is flawless. /s
Add Comment