Hard lessons I learn’t while programming

Old No Comments on Hard lessons I learn’t while programming 39

Don’t Multitask even when you are tempted

Usually when I am programming ,I do write a algorithm beforehand the program should do without putting much effort into it. I start typing out the program ,half away across the program oops I should have added that into algorithm.First I tried adding comments to the code,but it becomes a nightmare while searching for error .Like few hours later I don’t remember  or it takes unnecessary effort to understand code again and bug. If I become too descriptive, it becomes a pain in the ass to read the description.

Another huge problem is ,you think syntax  is easy but  while multitasking getting the syntax wrong is easy.Once you end up making mistakes it really hurts your confidence and drains your emotional energy.Getting the logic wrong the first time becomes a nightmare too ,because you are never sure its that segment of code ,or somewhere else or both .

How I make code more understandable to me

At first you think its my code, why would have any problems in the first place? But It is a big problem and that is why documentation is very important !!

First describe the function of the program, i.e every  intricate detail of the Main function and how the program will accomplish it .

Second keep all your main variables in one place

This fact hit me like I had a epiphany. You must be thinking what is so great about that ?

Keeping all your main variables (what I mean by that is those variables that is not used in for loops mostly,or just responsible for maintaining any loop ) and set it as a global variable .

This practice helps you read and understand  improve, and debug  your program the most radical way .Why you ask?

First when you have variables in one place ,you can interpret your program like a state diagram ,ie  every individual variable go through certain  stages or functions and undergoes a

change , and you have one look and see how your main variables are interacting with each other.  You can decide how your variables interact with each other and make sure after some

intense thinking ,your program intend to do what it is supposed to do

The real reason why I am pushing this far is ,all programmers undergo wishful thinking.

Hoping their code will do that something that they intended to do ,this style of programming removes the sparkles and fairies help from making your program work.

That is analyzing variables as States that undergo Process because of each function ,and other variables.

It essentially becomes what you really code is what you  get

That is what really awesome if you really think about it

Not only that it reduces duplicity, making you data private is much easier .

Guys I would love what you think about it ,and hear your Expert advice!!

 

 

Author

Related Articles

Leave a comment

Back to Top