
While working with beginner programmers, I noticed that many frustrations beginning programmers experience is because of their coding process. While programming can be very exciting, jumping into a coding process without much forethought can cause many frustrations and failing code.
Therefore, in this article, I will share my 5 step system for coding for beginners. This process works whether you are coding for data science, creating the backend of a program, or developing a GUI or website.
Instead of jumping into creating your code, you want to start with a clear vision of your output. This output can be the result of one step of code or the first version of your program.
Before your write your first line, you should know (and write down):
What the final product will look like
What the final product will do or show
The functionalities you want your code to have
For each step of code, what you want it to output
How your program or code will be provided (i.e. markdown, web app, desktop app, mobile app)
Now, one caveat is that all of these things will be tentative. As you start creating your code or program, you may change these things. However, having a vision from the beginning will decrease your frustration throughout the programming process.
For example, when I created a GUI API program to search an online database, I knew I wanted my program to:
Be a desktop GUI that non-coders could easily use
Allow users to paste a series of chemical formulas
Receive an excel file of the number of possible chemicals for each formula and gives examples of those chemicals
The next major frustration is that beginner programmers often don’t consider the order that which steps should be completed. I have seen beginner programmers complete steps out of order and wonder why their code is not working.
Therefore, you should create a general order of accomplishments based on what will be needed for every step of your code.
This outline can be as high-level or as detailed as you would like. When I first started programming, I liked having a more detailed outline of my steps with each portion of code accounted for. I found that it helped me to have a clearer structure to my work.
Now, I like having broader accomplishments outlined that I needed instead of every step accounted for.
A trick with outlining is that you do not always need to outline in the order your program will work. Often, you want to build essential functionalities first, then build additional features and interfaces.
In my example project, I outlined my project as:
Develop API code to take in defined formulas and output matching chemicals (Essential function)
Manipulate the chemical information to generate counts per formula and output an excel file.
Develop an input GUI and prepare the input for the API code.
Develop an output GUI for users to save their files.
Develop a processing GUI to let users know what the program is doing as it searches the database (optional).
As you can see, instead of starting with the input GUI, I actually started with the essential functionality. If I could not get the API code to work, the rest of the project would be useless.
Now that you have an outline, start with step 1 and write your code step-by-step. The important part of this is to test your code after each step.
Each step in your code is not necessarily a line of code. Instead, when you are starting, you want to write code testing each potential output. For example, if you are importing a package and then pulling something from that package, you do not need to test the import package and the from that package.
Instead, you want to test each output from your code. This could involve printing or showing outputs in certain programs (i.e. Pycharm) or simply running your code (i.e. Jupyter Notebook).
Testing your code step-by-step allows you to find problems one step at a time. This way you know where your code was still working and have narrowed down the potential problems in your code.
There is nothing worse than writing multiple lines of code and running it only to find multiple problems in your code.
In my example project, I wrote and tested my code step-by-step:
After developing the API code
After manipulating the returned data
After saving an excel file
After creating the input GUI
After creating the output GUI
After creating the processing GUI
Another major frustration is when beginner programs write a complex piece of code only to find it doesn’t work. Now, the next step is to find what the issue or issues are with the code.
Instead of writing what you hope to be your final piece of code, start with the simplest request you can make that begins to look like your final output. Once that works, you can then increase the complexity of your code until you arrive at your final product.
In my example project, I did not start will inputting multiple chemical formulas and managing how I received the data.
Instead, I started with submitting a single defined formula and just receiving chemical records. This was the simplest request I could make.
Once this worked, I started creating requirements for what type of chemicals it would search and how it would return the data.
Finally, I tested multiple formulas to make sure that it worked.
While this may seem simple, I had to go through several iterations of solving problems and retesting, before my code finally worked. If I had started with my final code, I would not know all of my problems when it failed. This could have easily led to me quitting the project.
The biggest problem I had as a beginner programmer was changing too many things at one time and breaking my code.
Sometimes, it is so tempting to make these three changes real quick that should work fine. Then, you run the code and nothing is working.
Which change is making your code fail?
The easiest way to solve this problem is to simply only make one change and then test your code. While it may take a little longer to write your code, the frustration in coding when starting out will decrease.
For each step of my code in my project, I changed one step and tested my code.
For example, this was my process when I tested chemical formulas:
Start with 1 formula defined in the request code
Define a single formula in a variable
Add another formula to the variable
Add a formula that did not have a matching chemical to the variable
Following this path, allowed me to find multiple issues one step at a time.
If you enact this process, it should help you to lower your frustration while coding, especially if you are a beginner.
The reality of programming is that your codes will have errors. However, consistently seeing errors in your code can be incredibly frustrating and can even convince you to give up.
My goal is to help more beginner programmers to keep learning and growing their programming skills by reducing your frustration so you can create more!