Making the code, test, and find fault (debugging)
Very simple and beautiful when we write programs that will run 100% without any errors at all. We stayed pressed the run button, and everything goes according to plan.
In fact not the case
Try to replace one of the few examples that are given by replacing one of the brackets {a (. Then in Eclipse, run with "Run -> Run". See what happens.
Eclipse will display an error message, it means that the syntax, or format of the writing program there is a mistake, and you must fix it before the program can be run.
The syntax is one way to determine how computers should work. Humans do not need a syntax to talk because people can determine where the subject, predicate, or object easily, even for sentences that have never read or heard though.
For computers, syntax help manage computer logic, which is a variable, which is a subroutine, where the loop, where branching and others. In the Java language, a language with strict syntax, it makes little difference in syntax for Java does not understand what is meant in the program. For some programmers, Java ketidakluwesan may inhibit, but keep in mind that only comes from human error. Java Ketidakluwesan help programmers must use the correct logic, and may not be wrong in using the variable. Variable is already defined type can not be changed middle of the road, except by creating a new variable with different types.
Debugging When your program does not show a syntax error, it does not mean your program is free from error. The program must be tested if he runs as expected. Idealya if the program receives input that is not as expected, the program will give a message to the user about the error, not a sudden exit without a message. We may have to make testing more slowly. If the number of rows in our small program, maybe the mistake we will easily meet. But if the program is very large, then look for errors that seem simple is not easy. Search this mistake in the programming language called "debugging", which if translated into Indonesian language means cleaning the lice, because a small error is considered as a interrupt the flea program. Eclipse provides tools for debugging, ie by pressing the "Run -> Debug". In Eclipse, debugging can be done include: create a breakpoint (a place to stop the program), execute one by one command, execute a subroutine, see the current contents of variables, and even replace the variables when the program starts.
Running the program step by step If you already are in debugging mode, you can perform navigation to make the execution as you like. There are a few choice provided by Eclipse, everything is contained in the Run menu, namely:
• Resume continuing program execution stops. • Suspend pause the program under way. • Terminate to stop the current debugging session. • Step Into executes the ONE command or entering the subroutine. • Step Over executes the ONE command. If the command is a command subroutine call, then the subroutine will be executed without entry into the subroutine that called it. • Step Return to execute all commands in this subroutine and then return to their callers. • Run to Line run the program from the line where cessation programs are now up to the line that you specify.
Or if among them there is another breakpoint, the program will stop at the breakpoint.
source: http://java.lyracc.com/artikel/java-untuk-pemula/perancangan-algoritma







0 komentar:
Posting Komentar