A novice developer often does not think about what the program is intended for and how it will be used in the future. For many, compliance with code quality standards comes to the foreground, also most developers do not care how this code will be used in real life.
If the project manager is not experienced enough or does not have time to dive into business processes, a situation may arise when the program works correctly in test mode, and when switching to the production version, it shows a bunch of errors and shortcomings. We'll figure out what a novice developer needs to consider so that development is useful to the end user.
Step 1: Do sanity checks
Novice developers often implement "good" algorithms that work great with the "right" data. They do not pay attention to the behavior of the program when “incorrect” data comes into it. Namely, this is usually the first thing that happens as soon as the program starts working in a production environment.
It is difficult for the programmer to take into account absolutely all possible situations, but to work in this direction is necessary. The algorithm should have sanity checks in each block of code and generate messages for the user indicating warnings or errors in the data.
Step 2: Try to think as a user
Another difficulty may be associated with users of the program. Any user, even with clear instructions for working with the program, can always enter such a combination of buttons or enter data that will break the “good” algorithm if the latter does not have any protection.
For these purposes, large projects often have testers or automated testing tools. The question is what to do if you don’t have such resources.
It is actually not as difficult for a developer to imagine himself in the user's place as it might seem. Users are human too and are capable of making mistakes. You need not to be too lazy and click on all the means of navigation, as well as enter incorrect data in all possible fields.
Step 3: Comment on the logic of the code when writing it
It is difficult to train yourself to write program code and immediately explain its logic in the comments. An explanation is needed here: you do not need to decrypt each line and obvious things like initializing the values of variables, but the purpose of small blocks of code can be easily described with one line of text.
In most cases, one clarification for every 10–20 lines of code will be enough, this will greatly simplify subsequent support and modification of the application.
Step 4: Do Not Delay For Later
Developers can themselves create implicit problems when working on a multi-day task, when they deliberately skip minor blocks in the code. For example, advanced data checks before processing or logging where it is not necessary. This can subsequently prevent you from dealing with errors in the program.
Such things do not look too significant compared to other tasks. It seems that you can skip them and return to them later. The most difficult thing is to realize that then it may not come. After testing and fixing defects for improvements, there is often simply no time left. Do not skip or put off anything in the implementation of the algorithm, especially if it takes more than one day to work on it.
Step 5: Keep calm and have enough rest
Often we find ourselves in a situation where time is running out: everyone has an emergency. The rush in software development leads to the fact that the output program is able to run and perform some actions, but has serious failures in the structure.
In the best case, the code may contain a bunch of “garbage” left over from attempts to solve algorithmic problems. And at worst, a program may simply not be sufficiently debugged and tested to cope with the full range of business processes assigned to it.
This will necessarily lead to the need to often modify the program due to constantly occurring incidents in a production environment. A sober assessment of one’s capabilities and a calm implementation without panic and fear do not need to be in time.
What other tips for beginner programmers do you have? Write in comments!