Hello, today we will talk about debugging.
What is debugging?
Debugging is the process of finding and resolving defects or problems within a computer program that prevent correct operation of computer software or a system.
So debugging means to find and fix errors, there are various ways to do this.
- Print output on the screen
- Create Unit tests
- Create Integration tests
- Debug using a debugger
So what are the different types of debugging?
There are many different types of debugging, below are some of the most common
Print output to the screen
The easiest way is to print the output of expressions or the state of variables to the console using
Create Unit tests
Unit tests assert the correct function of the smallest piece of code you have e.g. methods
There are various frameworks out there, most popular junit.
Create Integration tests
While Unit tests, verify only methods, an Integration Test asserts an complete Module of code e.g. a payment module. Typically Integration Tests take longer to complete as they are bigger and often access a database.
Use a Debugger
This is what most people have in mind when they hear debugging. Using a debugger is a skill on its own. If you use IntelliJ check out the debugging cheat sheet