Program Test Data and Troubleshooting Tools for Java, Visual Basic, and Python
The next three entries in this blog are designed to explore basic processes needed to write better, more bug free applications. To provide a reference for the methods that will be discussed, I will examine how these methods pertain to Python, Visual Basic, and Java.
One of the first methods to avoid bugs involves creating a framework for checking the validity of the data being entered into variables in an application. This process involves making sure the variables are declared, and that data is entered within the correct range, so that it “passes the sniff test”. If a variable is supposed to be either a true or false entry, and someone tries to insert “3” into the variable, things are not going to go well in application land. The solution is to declare that the variable has a Boolean data type, which will only accept a true or false (or a 1 or a 0, depending on the language). For numeric data, defining minimum values and maximum values for each variable will ensure that the correct range of data is entered. This can also increase the security of the application by ensuring that enormous variable values aren’t entered for the purpose of crashing an application in an unprotected state, possibly allowing a hacker or virus to have elevated privileges into core computing components.
Let’s look over the data types that are used in Java, Visual Basic, and Python:
● Java has only three data types: Integer, Boolean, and Character. Java has a defined set size for data types no matter what hardware platform the Java application is running on.
● Visual Basic has the most data types of the three languages being compared, eleven in total: Boolean, Byte, Single, Double, Date, Currency, Integer, Long, String, Variant, and Object.
● Python has 10 basic data types: Numbers, Integer Numbers, Floating-Point numbers, Complex numbers, Sequences, Iterables, Strings, Tuples, Lists, and Sets.
Declaring variable data types early and being very detailed and consistent with data type declarations is critical to avoiding unnecessary junk data from causing logic problems. This is a circumstance where painting outside of the lines is not a good option. Define the type of data that a variable should contain, and ensure that all data is correctly formatted. Part of the program architecture must include an acceptable range for all variables used, with the minimum necessary chosen to conserve memory space wherever possible
Each of these three applications also has various methods of detecting logic failures. In all three, the use of programming tools will often find problems before the program has ever been compiled to run. A compiler or Interactive Development Environment (IDE) will show the programmer in advance that there are basic syntactical errors or exception errors (things like a numeric divide-by-zero error, for instance). Another tool used by Java to assist with troubleshooting is an exit code when a process thread is no longer able to continue execution, either naturally, when the program reaches its natural conclusion with a normal termination code, or some other non-zero termination code that results from some type of error.
Java will provide output (called a dump) of the elements and methods that were in use by the module at the time an error occurs while the program is running (called run time errors). A programmer can also create test print statements that can be removed at a later time that create virtual bookmarks to allow the programmer to see where a sudden failure in the code may have occurred. This provides a way to monitor the progress of the application as it goes through its modules toward completion.
Java has built in aids to debugging programs for common errors such as Java PathFinder, Java DeBug, and the tools that are built into various IDE platforms. The Java Bug database is a well maintained database of common application bugs that can also assist in the programmer in troubleshooting issues.
No comments:
Post a Comment