What do you look for when examining posted code?

I was wondering whether there would be some value to having a thread in the Introductory Tutorials section that details what errors people are looking for when trying to help someone posting for help.

Although the view counts in that area are quite high, the number of new posters that don't use code tags shows all too well just how little the stickies and tutorial threads are used. So perhaps this is a Bar Sport topic instead.

If someone is reporting mysterious crashing behaviour after some time, I'll run my eye down their code looking for String, malloc or recursive calls. If I find any of those, I'll say so but I'm unlikely to dig further.

After that I'll look for exceeding array bounds.

If the issue is that things go haywire after thirty or sixty seconds, I'll look for an int used with millis().

If things are slow, check for 9600 used as a serial baud rate.

Always check for the ever popular test Serial.Available()>0 and then read multiple characters.

= != ==

I'm sure that there are other things I do too, depending on the request but I'm drawing a blank on any more right now. What do other folks start with?

Semicolons where semicolons shouldn't be.

Probably less common:

Global and local variable with the same name.
Local variables accessed in a different function (scope error).
Missing curly brackets to enclose a code block.

conexión de grounderoes

Qdeathstar:
conexión de grounderoes

¡Quiéralo!

Proper indents. I often copy to PC and T for starters.

A lot of obvious mistakes show that way.

sterretje:
Proper indents. I often copy to PC and T for starters.

A lot of obvious mistakes show that way.

Yes, same here, I copy via Notepad++.
Then using programming pins, then pullups/downs.
Tom... :slight_smile:

And then compile it with max warning level. That's found the problem on any number of occasions.

Sorry, the first thing I do is "Take a deep breath".... :slight_smile: :slight_smile: :slight_smile:

TomGeorge:
Sorry, the first thing I do is "Take a deep breath".... :slight_smile: :slight_smile: :slight_smile:

. :smiley:

If the OP is just asking for someone to review a program I generally give it a miss. I am not good at spotting mistakes without trying to run a program.

If the OP has given a sensible title to his Thread then that often gives a clue to the solution before I ever look at the program. Then I look at the program to see if my guess was correct.

Where there are lame titles like "I need help" I do often look at them and my first approach is to try to identify the question, or to ask the OP for clarification. Several times I have not been able to help beyond suggesting a better title.

...R

I've read so much code that I'm looking first at

how long it is --- do I have time to spend on this?

does it make sense? --- or is it like a Trump/Palin transcript, meaningless drivel.

mostly or all lifted code --- let's see what the OP thinks it does

is specialized and outside of my experience --- good luck!

is written with no arrays but certainly needs them --- try to get the user to learn all the ABC's and more than 2 words before writing that novel.

It's not a strength of mine but if it looks simple enough I'll examine it. However, if a poster won't even make an effort to write up a semi-coherent description or puts down two paragraph's worth of stream-of-consciousness run-on sentence, I just pass.

wildbill:
And then compile it with max warning level. That's found the problem on any number of occasions.

Problem often is that one doesn't have the relevant libraries. So compile will already fail on some of the includes :slight_smile: Or different libraries (with not quite the same functions) with the same names :frowning: