Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

I'm rewriting my code around 10 times before finishing. Is this wrong?

Tags:

workflow

When i start writing something complex, I find that restart the writing like 10 times before I end up with what I want, often discarding hundreds of lines of code.

Am I doing something wrong, or do others have workflows like this?

EDIT: Right now, I'm working on a modular compiler. The last project I was working on was a server in java. Before that it was some concurrency stuff.

I do a fair bit of planning, and I never start coding before I've got interfaces for everything.

Given that, is it normal to just wipe the slate clean repeatedly?

like image 734
Ritwik Bose Avatar asked Dec 29 '09 05:12

Ritwik Bose


1 Answers

Discarding many lines of code is usually a positive aspect of refactoring. That's great. But starting over ten times means that you probably haven't analyzed your problem and solution. It's fine to backtrack and sometimes to start over but not that often. You should lay out your code in such a way that when you backtrack and refactor, you keep most of what you created because it will exist in nicely isolated and logical chunks. (Using vague language since language of choice wasn't specified.)

From author's comment:

Usually I restart because I get confused by all the stuff going on in my code.

Study your craft and make good use of design patterns and other best programming philosophies to lend your code a well-defined structure... something you'll recognize months and even days down the road.

like image 199
Paul Sasik Avatar answered Sep 20 '22 06:09

Paul Sasik