Repetition for the programmer: why it is important to solve similar problems

    From the translator: today we are publishing an article for you by novice developer Amy Haddad. It tells why programmers should go back to already solved problems.

    Many developers give the same advice: solve as many problems as possible in order to constantly receive new experience and knowledge. This is good advice, because solving problems with code allows you to learn new things and improve existing skills. But I also consider repetition important: the same problem can be solved in different ways. And such repetition also allows the programmer to get a profit in the form of improving skills.

    Skillbox recommends: a two-year hands-on course “I am a web developer PRO” .

    We remind: for all readers of "Habr" - a discount of 10,000 rubles when writing to any Skillbox course on the promotional code "Habr".

    Know what i don't know

    If I managed to solve the problem for the first time, it does not mean that I can handle it again.

    I remember the situation with one library and an error in it. I managed to resolve this issue, although I was stuck on it for a long time. But after a few days, I again encountered the same problem, and I myself had already forgotten the primary solution. So instead of quickly rushing through this place and moving on, we had to spend time again.

    Then it became clear to me that I needed to work more with conditional operators and functions. And I also realized how important the study of problems is - it allows me to check my own knowledge and see the gaps that need to be filled.

    Working with buggy code gives a new experience, as already mentioned above. It's cool that I can solve the problem with the classes at the time I study them. In this case, everything looks pretty simple. But what if this happens to me in the near future? In this case, I will be able to understand whether the new knowledge gained earlier has been learned or whether it is worthwhile to consolidate it.

    Old problems, new solutions

    Even when I remember my actions when working on a task for the first time, in the second I try to find a new solution to improve my skills. For example, I solved one of the problems in the code with the help of Loop. The second time I found a new solution, and the code became more logical and readable. I managed to reduce its volume by 50% in the problem area, and as a result I received not only an understanding of how everything should work, but also figured out the nuances of the process.

    In another similar task, Loop reduced the amount of code and made it more readable. But within the framework of the “repetition” I solved the problem without it - to make sure that I could find an alternative solution.

    I can say that working through the problems brought me out of the comfort zone, so I began to think in an unconventional way. Only because of this and managed to find an alternative solution.

    Learning to write tests

    This is the third time I'm reading the Brian Hogan Exercises for Programmers book. I analyze his examples and each time I try to find a new solution. This time I practice writing my own tests.

    Here's how it works: I choose a random exercise from a book and sit down to code. I break the resulting program into several files, where everyone is responsible for a separate solution. And then I write tests.

    In the end, I want to learn how to write a test first, and then the code, but this is still ahead. Now I am practicing creating and highlighting functions and importing files.

    The constant repetition of exercises allows you to form patterns that are deposited in the head. Further, they can be used as a mental model for solving new problems. By the way, this advice I saw in the book of George Paul How to Solve It. He advises when solving a new problem to look for a connection with any existing experience.

    “Think about what helped you in a similar situation in the past. Look for something familiar in the current problem, try to use your experience. "

    Paul is right. I do quite often use previous experience to solve problems of a new type. For example, I recently worked with anagrams. I managed to solve one of the current problems with the help of the experience gained then. Despite the fact that the previous task was simpler, it made it possible to find a new solution.

    Working through the problems gives the programmer a lot of useful information. We form new concepts, strengthen old ones and create a knowledge base, which then forms the basis of the work.

    Skillbox recommends:

    Also popular now: