Unit testing
It is generally agreed that writing bug-free software is impossible, especially when your code runs on third-party hardware, such as a mobile phone, and needs to interact with users, who can (and will) do all kinds of unexpected things.
For some situations, such as reusable function libraries, the requirements can be well defined, and the data inputs and outputs known in advance. In these situations, not only is a strong set of tests a great way to ensure the library is as bug-free as possible, but you can make changes to the code (for example, performance improvements and memory optimizations), knowing that your changes have not affected the expected behavior of the library.
Unit tests are one of the tools that can help us write modular, efficient, and bug-free code. A unit test, as the name implies, tests the smallest logical unit of code that can be meaningfully executed in isolation. The unit test is not the only way of testing code, of course, but it’...