Is Rewriting the Same Function Several Times a Normal Part of Learning?
Asked by
MellowHarbor42
I'll write a function that seems correct, then revisit it the next day and end up redesigning most of it because I finally understand what I was trying to accomplish. Sometimes this happens four or five times. Is that a normal part of learning, or does it mean I'm too slow at understanding concepts? Do other beginners go through the same cycle, and are there practical ways to make new ideas stick faster?
Answers
Rewriting can actually be part of the learning process rather than a sign that youโre behind. Each version helps you understand the algorithm and the problem space more deeply. Even experienced developers revisit code repeatedly, and sometimes they end up almost exactly where they started.
Reply to this answer
A rough first version is often just a way to make the problem concrete. You might begin with a straightforward list of steps, get it working, and then improve the flow or performance. That kind of iteration is normal, especially when youโre still learning how to recognize better designs.
Reply to this answer
Try sketching the design before coding. A small diagram, a list of parameters and constraints, and comments describing what the function should do and why can keep you from repeatedly changing its overall structure. Once the design is settled, you can focus on improving the implementation instead of starting over each time.
Reply to this answer
Itโs similar to learning a song: most people need to hear it several times before it sticks. Coming back to code later gives your brain another chance to process the idea, so the next rewrite may be less about failure and more about gaining a clearer understanding.
Reply to this answer
Thatโs completely normal. A useful habit is to write one sentence explaining what the function is supposed to do before you start coding. If you canโt describe it clearly, that usually means the problem itself still needs to be worked out. Doing this made my rewrites much less frequent.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions