Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Programming "What-if"?
#5
JoeTang Wrote:I believe it's only bad practice if the pointer name is ambiguous and is used in significantly longer sets of code. Since yours is contextually relevant to what it does, and there's only two lines, it's simple to understand and no confusion should occur about it being reused for a different purpose or the value being changed in such a way that would be difficult to follow by hand.

Correct practice would be to have anything named to be contextually relevant, and simple to read and understand from a third person perspective.
This. It's ok because the variable name is accurate and descriptive in both uses and the uses are very close together. If the uses of the variable were different and you were just trying to save 4 bytes, that would be bad. Code readability > 4 bytes (and the compiler might optimize it so both variables use the same memory location anyway).

By the way, if there's no reason you need to use C instead of C++, you should use std::vector and std:Confusedtring instead of raw dynamic arrays whenever possible. Manual memory management is error-prone.
Reply


Messages In This Thread
Programming "What-if"? - by Fiel - 2009-08-24, 05:04 AM
Programming "What-if"? - by Tikey - 2009-08-24, 06:00 AM
Programming "What-if"? - by parshimers - 2009-08-24, 06:08 AM
Programming "What-if"? - by JoeTang - 2009-08-24, 06:55 AM
Programming "What-if"? - by Spaz - 2009-08-24, 12:34 PM
Programming "What-if"? - by GummyBear - 2009-08-24, 08:26 PM
Programming "What-if"? - by Nikkey - 2009-08-25, 03:45 AM
Programming "What-if"? - by JoeTang - 2009-08-25, 03:46 AM
Programming "What-if"? - by Fiel - 2009-08-25, 01:50 PM
Programming "What-if"? - by GummyBear - 2009-08-25, 08:32 PM

Forum Jump:


Users browsing this thread: