Seven effective programming habits to help you become a better programmer

   Programming ability and level are important, but if you have good programming habits, you can often help you do more with less. The author of this article shares seven effective programming habits through personal experience, hoping to help everyone.
                                                                              
Recently, I was reading some good books on habit formation. After reading it, I was very enlightened. So, I began to reflect on my current habits. Some of them are habits in daily life, and some are only related to work. When it comes to work, I have to talk about programming habits. I am happy to share my programming habits with you.

"Ctrl+S" anytime, anywhere


This is a habit I have been sticking to for many years, although many new IDEs don't even need to save manually and can save automatically, but I still involuntarily press the key combination "Ctrl+S" at the end of the code, if If I remember correctly, I "Ctrl+S" every time I stop typing on the keyboard, but oddly enough, this "Ctrl+S" actually saves me more of the day than the smile on my coworker's face. time.

Regularly free up brain memory


Some programmers say that typing code for a long time makes them feel like they are in heaven, and it feels great. This is a kind of "rage mode" in my opinion, which may make people feel good in the short term, but Then you will need to spend a lot of time repairing yourself. So, brainstorming for a short period of time is okay, but you need to stop and take a break at the right time. Brainstorming for too long will actually make you think slowly and easily lead to a dead end.

Make sure to rule out any distractions


When I'm concentrating on a very important thing, I turn off my phone, avoid social media or any unnecessary media distractions, and of course, listen to some music. But then again, a healthier approach is needed. If you have kids and you need to be very focused on your work, keeping them in the basement in order not to be disturbed may sound like a good idea, but it's not a good solution in the long run.


start with the end


It has been said that the power of visualization is unparalleled in helping us identify goals for the day and ultimately reduce or eliminate negative emotions like depression and disappointment at the end of the day. So, at any time, you must know exactly what you want to do. It sounds obvious and easy to do, but in practice, this step is often overlooked.

regular training


I have a good habit of training regularly. Of course, going to the gym is also a good habit. In this case, I am more concerned about a person's actual programming ability. I'm passionate about keeping my mind sharp through improvisational coding training, which may not yield significant results in the short term, but one day it will accumulate.


Start by writing test cases


One of the most common patterns in recent times is to start with writing test cases no matter what code you write. This comes from an early point of mine. It helps me see the destination before starting. Obviously, this makes the final result. More secure and reliable, while still being able to design and document code, I am surprised that few programmers agree with this point of view.


Don't "plan ahead"


Another is my new habit of avoiding "forward planning." I didn't understand this principle before, I always wanted to do it all in one step, I wanted to consider all aspects from the beginning, I wanted to cover all possible test cases, and I even wanted to use my descendants. Also take that into consideration. Gradually, I realized that this would lead to an overly complex and time-consuming code base, and the most common result is that my code is flawless and useless at the same time.

Finally, if you think what I said is in line with your taste, try it! These are indeed very helpful for my programming, but Rome was not built in a day. The best way to develop a habit is to use it. One day you will suddenly find that the habit has been formed unknowingly. Ha, if you have some good habits, remember to share them with me!

                                                                          

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326301937&siteId=291194637