We, programmers, spend a lot of time learning newer technologies, programming languages, implementations, algorithms, and yada yada yada. We see loads of problems each day and try to solve them as efficiently as possible. Efficient be it in terms of size or speed. We understand the question, frame the possible flow of the program, think about the end product and bask in the glory that is yet to come. But, when it comes to actual programming, we often face this one issue – “What do I write first?”
Well, it may seem obvious at first for any programmer who uses non-templated code that the first line of code must be – “#include <…>” for C/C++ or “import java….;” or “class ….” for Java. Well, my friend, what we really are concerned about here is the first line of code within the main() function. Now that we are all on the same page (except for Python programmers), let’s understand our problem.
Our problem states that a coder faces a coder’s block when he/she has to write the first line of code after they have planned out their entire route to success, that is, solving the problem that they intended to solve. What we need to know is that such a block is a very valid problem, considering the fact that there are multiple ways to approach a problem. Also, in the world of programming, there are tons of options to choose from when it comes to manipulating one single line within the editor. This array of choices leads to an obvious confusion within the mind of a programmer so as to know where to start from. If the question was as simple as adding two numbers, it would be very apparent to declare three variables – two operands and a result variable – at the start of the program. But, even the declaration and definition has a variety of ways to be carried out. I understand this might be a bit of an exaggeration, but it is what it is in the corporate world.
Bigger questions tend to cause more confusion if they have complex systems within themselves. A better way to tackle such situations is to break down these problems into smaller units and solve them little by little and after which, they can be combined to get one major solved answer. Similarly, we can try and understand what all data structures our program needs. Also, the knowledge of what algorithms we will be using would be helpful. This is so because we can initialize all of these data structures, write the logic for them and keep track of counters in the initial part of our program. This helps us keep track of the main elements that we will be dealing with within the code.
Comments are friends. They help you understand your code. Yes, there are times when you can’t understand your own code. Now you know how you could help yourself as well as your fellow programmers understand what is written in that editor. But, as with many friends, having too many friends can be difficult to handle. Hence, moderation is always the key.
Why were comments talked about so suddenly? Well, in your initializations, comments can be used in order to understand what each and every variable or a group of variables are doing. This helps in setting up an idea of how we want our code to look and how do we go about actually coding the rest of the solution.
Last but not the least, we have the introduction of the program. You could put up some pretty formatted print statements at the start, create a menu based program or simply analyse your own written content to try and get an idea of what you’ll need next.
That was it from my side. I hope I could shed some light on one of the issues faced by programmers and in some way managed to help you find a solution to it.
Until next time!