Every web developer, from junior to senior makes bugs. In our entire web development journey, we’ve made hundreds at least. Those are the ones that we aware off. In our opinion, it is okay to (accidentally) make bugs because people (developer) make mistakes. But you have to fix those mistakes. Fixing important bugs will make you a valuable developer. Instead of focusing in fixing bugs, you should try your best to prevent it from happening on the first place. Read on to find out what are the easy ways (and proven by Melbourne web developers) to avoid bugs.
Form Validation
For every CRUD app, forms are crucial. You have to pay attention to form changes, new fields, controller changes. Unexpected behavior mostly caused by form related changes.
Let’s say you create a new form field. Immediately correct the form validation. Then, check all the possible form inputs, check the validity of the new HTTP request. Be sure to thoroughly check each page using the form, shared forms also can lead to serious bugs.
You can loosen frontend validation a little bit, but the backend should cover the rest. Ensure that your validation covers all special, invalid characters and that limits are correct.
Handling Lists and Maps
Every web app use lists and maps to properly present the data. Serious troubles could happen when it handled badly.
Edge cases around lists are numerous. Possible errors for lists:
- empty lists
- displaying errors
- mapping errors
- reducing errors
Create good coverage with unit tests in order to prevent bugs from list handling. Edge cases are almost always problems with lists. Bad mapping cause output values.
Code Leftovers
When removing or adding new feature, sometimes we produce some waste. This waste commonly called code leftover and it can lead to errors. Keep in mind to check any leftovers after editing your codes, especially when you were jumping from one thought process to another.
Handling Conditions
Naming conditions can often lead to problems. Difference between naming “variablesetPropertyToTrue” and “disableCaptcha” can help out a lot.
Avoid negative for flags. For example, “notYetUsedProduct” should be “!usedProduct”. This way you won’t run into pesky bugs with flags, especially if there are multiple conditions.
In order to make debugging process easier, avoid using ternary operators. Instead, extract all flags into separate functions and variables. It is easier and shows intent right away when working with separate conditions.
Test Edge Cases
Follow the code and test it. Last but not least tip. Be sure to cover all the edge cases. Consult with other developers, try to find another approach of testing.