Computer programming is an area that can have three major types of errors that can happen. One is known as syntax, which is common when starting out. There is also the runtime error, which can cause a program to terminate unexpectedly if an exception is not thrown. The final one is known as a logic error and can be a bit difficult to catch but not always. Learn a bit about them with examples of how they could happen.
Computer programming is an area that could have potentially three types of errors. As far as working with them, it can happen. The one you don’t want is known as the syntax because the program or web site depending upon the skill set will not function properly.
Perhaps the most common is known as the syntax error. It is the one component that does not allow a program to continue to be written. As far as the way it works, it happens during the process of compiling and building the program. Depending upon the programming language being utilized, it goes through that exact process.
A possibility is that there could be a spelling error. That would have to deal with variables more than anything. Depending upon the type of program being developed, it could happen. Sometimes it could be there without realizing it and it does happen. Nevertheless, the best way to correct it would be to make sure that all variables match from top to bottom.
It should be mentioned that it is possible that there could be formatting. In some languages like C++ or Java, there is a semi colon that is needed to end a statement. It could be overlooked slightly but depending upon what program that is being utilized, it may indicate it. For example, Visual Studio 2010 will show it with C++. Java is the same way.
Final example for this has to do with not initializing variables. For languages that are specific with the data type, it can really play a role. An example would be an integer type not being mentioned until getting to a statement without declaring it formally. Languages like PHP or Perl do not need that, however, there will need to be a dollar sign in how it is set up.
The runtime error is a specific type of error that can cause a program to terminate abnormally. That means that some command could be put in that could cause the program to terminate. That does not mean it is the same as a syntax error. It is one that happens during the execution of a program.
To prevent the problem or at least cause it to not terminate would be using what is known as exception handling. That means what would be known as like a try-catch command. It is a tool that can be used to catch what could be an abnormal setting.
An example could be involving dividing by zero. As it is known in Mathematics, you cannot divide by it and will receive no solution. A calculator will display an error message. If an exception isn’t thrown, it can terminate the program if trying to divide by zero. To prevent that from happening, go with a try-catch command. An example could be shown with the link on setting it up with C++.
Possible example is working with the combination of a program utilizing a database. How could this be possible? Sometimes it could appear in the form of a SQL command being put in wrong. It could be a missing data type or misspelling a table name especially for the insert. There also could be some that could have duplicate information posted. In a database, it must be unique and different.
To finish up with the database portion, it can be the same for the update and delete. In the case of an update, it could be either the SQL syntax or it could be that updating the data isn’t working due to trying to change the primary key. It is not going to work that way. Deleting as well needs to be done correctly.
Arguably the hardest error to pinpoint is dealing with logic. Generally, that would mean that the program would not have any other issues as far as setting it up. To get this error, this would involve possibly getting an incorrect result. For example, it would be like adding two numbers and getting the wrong answer. It is one of the hardest to actually pinpoint even after looking it over.
As far as correcting them, one method that could be done is going over the code line by line to see if the error could be found in the program. It’s not necessarily an error that is going to cause it to stop working but just a matter of not getting the right result. See if you can pinpoint by yourself before trying to ask others. If that does not work, then perhaps maybe getting another person to look at it within a team group. Sometimes it is small and sometimes it is large.
HTML has become the language for web pages, and it not always easy to catch even the smallest errors. Missing or a misdirect DOCTYPE can create numerous errors in HTML code.
Missing character encoding: For most English web pages, the character encoding will be entered into the Web page like this:This meta tag should be within theandtags of your Web page and is not case sensitive. This is an easy error to miss.
One of the simplest errors is forgetting the opening and closing tags, like, (i.e., and ). This can mess up any web page, but is easily found when looking at the end of any command for the closing / tag.
These are items that are going to happen from time to time. The only objective is to simply get better at programming so that these types of errors can be kept at a minimum. They are going to happen from time to time as it is all part of the learning process.