Under Construction
There have been several errors that Don and I have seen over the past couple of weeks while helping with projects. We have compiled the following list of errors that you should check for if your program is not working or will not build.
1) Semicolons at the end of loops and conditionals.
--A semicolon on at the end of a loop or conditional will allow the program to build but will not perform as intended.
2) Not declaring the correct type of variables.
--Remember that if you are using a variable that may be set negative at some point during the execution of a program, it must be declared as an int.
--Remember that your variables for various types of ints can be an 8 bit or a 16 bit number. This will allow the variable to be different values.
3)ANDs and ORs
--ANDs are defined as &&
--ORs are defined as ||
--Parenthesis matter. If you are testing two things against eachother, make sure you have parenthesis around each item.
4)Brackets
You use brackets to define regions in code. Functions, conditionals, and loops all use brackets to define their scope.
5)Format and Comments
There should be at least a one line comment before each loop or conditional that describes what the following lines will be accomplishing. This helps debug code and better defines chunks of code.
Everything within a region of code has a format based on its region. In general everything within a loop, conditional, or function is tabbed once more then the heading.
main()
{
while()
{
if()
{
}
else()
{
for(;;)
{
}
}
}
}
OR
main(){
while(){
if(){
}
else(){
for(;;){
}
}
}
}
6)Updates - Too Many/Not Enough/Wrong Place
7)Battery not charged
8)Project not set up correctly
Refer to the programmers notepad guide.
Common mistakes are
Missing files
Incorrect files
9)Conditionals vs Loops
10)Distance vs Range