It is amazing how often students write many lives of code when a few lines would work better. There are several reasons, I think, why this happens. One is of course that they lack the tools – the specific knowledge of features and functions – that would make things simpler. I think most teachers try to create projects that can be done easily and simply without features that haven’t been covered in class. Unfortunately sometimes students don’t pay complete attention (imagine that) and so forget about features and use the ones they do remember.
That leads to a second problem for some students – they fall in love with specific features and functions. If you really like loops ever problem seems to call for a loop to you. As we gain experience we learn to avoid this trap but students are prone to falling for it. This is related to another problem.
“I didn't have time to write a short letter, so I wrote a long one instead.” ― Mark Twain
Yes, in their hurry students do not take the time to think about and design a simple solution. They create a solution in their mind that they don’t realize to overly complicated. As a poster in one of the other labs at my school says “Weeks of coding can save you hours of planning.”
Another interesting case is the show off. The student who really wants to impress the teacher with how much they know. These students occasionally try to do too much all at once and get lost in their own complexity. This is closely related to a lack of planning of course. These students often think that complicated code is “worth” more than simple code. They don’t always appreciate the work it takes to make things look smile and easy.
As teachers we try to talk about these things and prepare students so they can avoid these pitfalls. Somehow though a lot of students just have to learn things the hard way. Our job then becomes helping prevent too much frustration and assist in recovery. Once they have learned something of course.