Debugging as a beginner. Let's understand it.

It is confusing at times, where should one look when code doesn't work. Let's understand debugging.

When you are writing a code, often you are constantly changing things to match a output, to come to the output.

When you start doing that after a while your own code becomes unrecognisable.

You can't figure out what's doing what. Beginner mistakes are to change variable names at one place and forget that it is also called or referred in other file.

When things like that happen, the code becomes unreadable.

If you arrive at such a state, you should go back to basics. And a very basic thing before you even start to code is to write logically in plain English what are you trying to do.

Syntax does what it is supposed to do. It is doing it's job. But when you change things fast, most probably you are trying to fix one thing but fail to understand how different parts of program are linked to each other.

How a program or statement is reading the statement and how it is acting on how it is defined to work.

You have to sit down and logically restart on what you intended to do. Then you gather syntax to make it work. Then you test how far the code works. Do this till you get what you want. Now try to organize it so that it's readable for you.

It is normal to make changes but what happens is that some of the things can break because of it. You may suddenly see your previous code shows an error.

That is because programs talk to each other as you defined it to and if that talk is gibberish or unrecognisable it will stop to act further. You have to go logically then to understand what is working till where and what you want to do from there.

Once you understand what works and what doesn't work, you have to then establish a code that can proceed from where you are.

If you program something it will work for you but it will not work for everyone sometimes. You will then have to ask what is not working for them, understand their environment and make your code inclusive to handle everyone's needs.

It is a constant process of optimization if your user base is incredibly huge. But on a smaller case, lot many things are best to work on need basis only. Unnecessary additions only burden the process when only a handful of usecases are enough.