Live data from Hacker News

Throw away your first draft of your code

ntietz.com

31–40 of 230 posts

Re: Throw away your first draft of your code

#31
post #10

The temptation to throw away all of your code - be it a prototype or a "grown" code base - arises often. Often it is a bad idea. I get it, though, there is an inherent attractiveness in the idea of starting fresh from a clean slate. Except, more likely than not, you'll soon find yourself in a similar situation to the one you started from. The fundamental problem is that it is easy to underestimate the edge cases. Sur…

It says to throw it away after a couple of DAYS, which seems to differ from other advice (like from joel-on-software)

Maybe this is ok, given that time period?

or will the rewrite have all these extra bells and whistles?

or will the rewrite throw away the unneeded bells and whistles?

Re: Throw away your first draft of your code

#32

I like to build my first version in one file with as few abstractions as possible. No helper functions, unless absolutely necessary, just straight-forward code. Building good abstractions later on is a lot easier than starting with wrong ones in the first place.

Very interesting approach. As someone who has overengineered last major project I worked on......maybe this is the way. I got so fixated on getting it "right" using current standards and abstractions that it became a bit of a mess. I despise working with that code base now.

Re: Throw away your first draft of your code

#33
I've found this great on my personal projects where I've had all the time I've wanted. The next iteration was always orders of magnitude better than the first. In the professional setting I find that the prototype is often enough and rewriting costs unjustified amounts of money.

Re: Throw away your first draft of your code

#34
post #10

The temptation to throw away all of your code - be it a prototype or a "grown" code base - arises often. Often it is a bad idea. I get it, though, there is an inherent attractiveness in the idea of starting fresh from a clean slate. Except, more likely than not, you'll soon find yourself in a similar situation to the one you started from. The fundamental problem is that it is easy to underestimate the edge cases. Sur…

> The temptation to throw away all of your code - be it a prototype or a "grown" code base - arises often.

I want an editor plugin which allows me to mark sections of code as reviewed or "perfect" (depending on how honest I'm being). Then, when I'm tempted to rewrite everything, I can go through and mark what I think is good, and then focus on refactoring the rest until I think it is good as well.

I'm tempted to rewrite code because I lose track of what it's doing, or I've learned a lot since I wrote that old code and so I'm not sure if the old code is good anymore. It's not so much about rewriting the code as an exercise in getting familiar with the code I've already written. I want a tool to help me with this.

Re: Throw away your first draft of your code

#35

I'd rather do the Ship of Theseus thing and just harden the prototype as required, and only when faced with real-world evidence. The problem with rewriting is that sometimes you face second-system syndrome[1] where you overengineer everything. Believe me--it happened to me at Groove Networks after Lotus Notes (ask your grandparents about that). [1] https://en.wikipedia.org/wiki/Second-system_effect

Yet I find when rewriting from scratch there's a countering force of simplification where I find myself thinking "We spent way too much complexity on that part, and we can entirely do away with that other part, and we turned out never to use features X and Y."

Re: Throw away your first draft of your code

#37
I rewrote a mission critical application. The original app was something else. One function had 1500+ lines of code. It was the ugliest thing I have seen in my life. We wrote cleaner code in early college years. However, that code ran the business for 12 years with almost 0 modifications. People created work around for some stuff. Error handling was poor. But the goal was achieved and business continued to grow.

I think devs in general sweat too much about code quality.

Re: Throw away your first draft of your code

#38
post #10

The temptation to throw away all of your code - be it a prototype or a "grown" code base - arises often. Often it is a bad idea. I get it, though, there is an inherent attractiveness in the idea of starting fresh from a clean slate. Except, more likely than not, you'll soon find yourself in a similar situation to the one you started from. The fundamental problem is that it is easy to underestimate the edge cases. Sur…

Throwing away an established code base is a completely different thing from throwing away a few-days-old prototype, and not what the article is suggesting. The points you mention don't apply to the prototype case.

Re: Throw away your first draft of your code

#39
Anecdote: I know a guy who works solo and throws every project away (usually games) at least five times, often more like ten.

According to him, each iteration tends to go smoother and faster than the last.

Edit:

There’s probably some nuance to whether this approach is a good idea based on type of software, size of team, experience level, personal and/or team skill set, etc…

Re: Throw away your first draft of your code

#40
post #10

The temptation to throw away all of your code - be it a prototype or a "grown" code base - arises often. Often it is a bad idea. I get it, though, there is an inherent attractiveness in the idea of starting fresh from a clean slate. Except, more likely than not, you'll soon find yourself in a similar situation to the one you started from. The fundamental problem is that it is easy to underestimate the edge cases. Sur…

I've thrown away and redone a lot of code, both mine and others', and I've never regretted the time spent vs continuing to use the old thing.
Post reply on HN