r/ProgrammerHumor • • Sep 23 '19

Knowing how to code beforehand

Post image
7.6k Upvotes

264 comments sorted by

View all comments

Show parent comments

12

u/smcarre Sep 23 '19

How is a class not being capitalized or an unused variable an "error waiting to happen"?

31

u/Salanmander Sep 23 '19

So, here's what it really boils down to.

A warning that you understand is fine.

A warning that you don't expect is often indicative of a logic error, rather than a syntax error.

If the unused variable is there because you're saying "I'm going to implement this check, but I want to test the other things first", fine. If it's there because you just forgot to implement the check, then it's a ticking time bomb.

4

u/chinpokomon Sep 23 '19

And use attributes and directives, depending on the language/compiler, to allow the warnings you know about and leave a comment. This way, when you get a warning you don't understand, it might point out a problem you don't realize.

1

u/[deleted] Sep 24 '19

Bingo.

-18

u/smcarre Sep 23 '19

If it's there because you just forgot to implement the check, then it's a ticking time bomb.

No it's not. It will just mean the app will consume some extra bytes of memory. Maybe some KB, depends on the language and type.

7

u/retc3 Sep 23 '19

If you're in C/C++ you may have just introduced a major security flaw.

8

u/EishLekker Sep 23 '19

I think he meant that the logic is flawed.

9

u/Salanmander Sep 23 '19

Exactly that. If you initialize a variable to hold the divisor in some calculation because you intend to check whether it's zero, but never actually do that check, and some time later run into the weird edge case where it is zero, then your program crashes instead of handling the error nicely.

1

u/[deleted] Sep 23 '19

gonna error out in the linter obviously