Programming Tips

11 replies [Last post]
YuSheng.Chen
Title: NooBot
Joined: 10/28/2013
Posts:
BotPoints: 286
User offline. Last seen 5 years 11 weeks ago.

I am going to put a list of most common programming errors and why some bugs are caused. This is also a learning process for me so if you have any suggestion that can improve the reliability of your program, please post it. Also, I should have put this under a user article but I'm a bit lazy so I don't want to read the guidelines, yet...

1) The use of = instead of == to denote the equality of two objects (no objects in C of course).
2) The use of & and OR instead of it's short-circuit equivalent (well, not completely equivalent).
3) The excessive use of global variables and global functions.
4) In C++, don't use using namespace std.
5) Forgetting the semicolon (A classic).
6) Random use of signed or unsigned integers.
7) Use of variables that do not reach a large enough byte number.
8) When defining variables, forgetting capitalization.
9) Forgetting opening and closing brackets.
10) Forgetting that a variable is not defined within a class.
11) Trying to alter a function without the use of a pointer.
12) Forgetting to assign a address to a pointer.

If you have things you want to add to the list, please post them. This is also a learning opportunity for me. Cause I mean, wisdom is the accumulation of experience. And I would love to gain some experience.

Harrison Cassar
Title: NooBot
Joined: 10/16/2013
Posts:
BotPoints: 197
User offline. Last seen 4 years 10 weeks ago.

Ha, I know one: Forgetting to enable servos... :D

YuSheng.Chen
Title: NooBot
Joined: 10/28/2013
Posts:
BotPoints: 286
User offline. Last seen 5 years 11 weeks ago.

I mean general applications such as C++ and C as an entirety. I am not specifically referring to botball, but, yes, in botball, enabling servos is a common mistake, thanks. Oh, and, by the way. Check out, Jeremy Rand's informative article on enabling servos and disabling them. It is quite impressive.

ruler501
ruler501's picture
Title: NooBot
Joined: 01/29/2012
Posts:
BotPoints: 367
User offline. Last seen 3 years 50 weeks ago.

Using uninitialized variables for decisions.
Forgetting to free/delete and malloc/new memory
Forgetting to check if a pointer is null
Equality comparison of floats/doubles with ==

YuSheng.Chen
Title: NooBot
Joined: 10/28/2013
Posts:
BotPoints: 286
User offline. Last seen 5 years 11 weeks ago.

Thanks, great tips, I can't believe I forgot them, especially the = and == thing.

AmandaPanda
AmandaPanda's picture
Title: NooBot
Joined: 11/18/2013
Posts:
BotPoints: 144
User offline. Last seen 4 years 20 weeks ago.

I always forget the semi colon, I barely program, even though I really want to, but it never seems to compile the first time! It is always that semi colon.

Oh wait! I almost forgot ----> ;

Haha

Amanda
PDCMS

amanda southworth
Title: NooBot
Joined: 09/08/2014
Posts:
BotPoints: 18
User offline. Last seen 4 years 32 weeks ago.

the worst one that I made, was forgetting the create_connect();, and adding a semi-colon after int main. :(

peterstrong
peterstrong's picture
Title: NooBot
Joined: 07/05/2016
Posts:
BotPoints: 12
User offline. Last seen 1 year 34 weeks ago.

Forgetting to free/delete and malloc/new memory

Elvena Snart
Elvena Snart's picture
Title: NooBot
Joined: 02/23/2017
Posts:
BotPoints: 2
User offline. Last seen 2 years 8 weeks ago.

These common mistakes of programming become a headache when you are finding for a problem and you don’t know where to look for. I had alot of trouble on my site due to programming issues and some of the Assignment Writers related to programming field point it out later that my sites have common mistakes like a single = instead of two ==. These tips are quite reliable and it’s a mistake every programmer made but with practice and a daily routine of work you can overcome this problem.

Imesers
Title: NooBot
Joined: 03/31/2017
Posts:
BotPoints: 2
User offline. Last seen 2 years 3 weeks ago.

Thanks for tips. I need to print them out look through them every time I try to code. I'm so forgetful, brackets are my curse. Especially in JavaScript https://qubit-labs.com/hire-javascript-developer/

panistefanin
Title: NooBot
Joined: 05/29/2017
Posts:
BotPoints: 64
User offline. Last seen 45 weeks 17 hours ago.

I'm new and I'm interested in this topic. Thank you!
sprint corporate