Live data from Hacker News

You Should Write Ugly Code

redotheweb.com

11–20 of 56 posts

Re: You Should Write Ugly Code

#11
This all sounds great, but I've worked in places where this has been the philosophy.

Unless you have somebody in charge who understands the importance of code quality (and why a bad codebase can be a ticking time bomb) you will find it very difficult to budget time/money for the removal of technical debt.

You will often meet the attitude of "well it works now, why waste time rewriting it?" or "sure, do that. But let's clear this milestone first", "oh, priorities have changed we need to add this new feature first".

This usually gets externalized to developers who end up working excess hours firefighting a horrific codebase or implementing a bunch of features twice, once in the clean codebase and once in the dirty one.

I've had times where I worked 8 hours at work and then came home and worked another 6 getting the new codebase in sync to a point where it could be replaced.

And when people start loosing money because shit is falling apart due to a tangled, buggy codebase without proper tests guess who's ass is on the line?

Re: You Should Write Ugly Code

#12
post #9

> the code they wrote for the sake of beauty is crap. From my understanding, this is the crux of the article. The problem with this is the misunderstanding of why people employ patterns in programming. It's not for the sake of beauty, but because of sound architectural principles. Maybe that's how he interprets beauty, but then using the word beauty diminishes why the code was written the way it was written. That bea…

In my experience, "good" code and "pretty" code are the same thing - and similarly for "bad" and "ugly". Of course, when I say "pretty", I mean well laid-out, properly documented, non-spaghetti code. I've spent far too much of my time tearing out thousands of lines of "bad" code that wasn't written in a way to allow for easy changes.

My issue is the phrase "sake of beauty." This ignores why this code was written. I'm fine with beautiful code. My issue is the use of the word beautiful in such a way as to imply that beauty was the intent. People don't try to write beautiful code, people try to write good code. That it happens to be "beautiful" is a bonus.

Hopefully my point is clear. I guess it's subtle, but I think a crucial difference.

Re: You Should Write Ugly Code

#13
> Would you be willing to buy a piece of furniture twice the normal price because the craftsman uses the most expensive tools available? And what would you think of a poor craftsman who, using poor equipment, manages to create great furniture? Who's the best craftsman of the two?

The author forgot to mention most likely alternative here: a poor craftsman uses poor equipment to create poor furniture that breaks easily.

Re: You Should Write Ugly Code

#14

> the code they wrote for the sake of beauty is crap. From my understanding, this is the crux of the article. The problem with this is the misunderstanding of why people employ patterns in programming. It's not for the sake of beauty, but because of sound architectural principles. Maybe that's how he interprets beauty, but then using the word beauty diminishes why the code was written the way it was written. That bea…

I agree, his example makes a case for writing "beautiful" (maintainable?) code from the start.

Re: You Should Write Ugly Code

#15
We shouldn't write maintainable code because the idioms might not seem fashionable at some point in the future? Never mind that code is read way more than it's written and that maintenance costs way more than development. Building up massive technical debt is fine in the short term but eventually you'll have to address it and that's going to cripple development on the product. OOP principles aren't a fad, they're fundamental to structuring code in PHP.

The analogy with the furniture is particularly misleading. Would you pay half as much for a chair that occasionally falls over? That takes a long time to get repaired because each of the legs is tightly coupled to one another? I'd rather pay double for the reliable version.

I've worked with a lot of code bases in the past where the developers have had a resentment towards new methodologies and saw people who tried to use new ideas as just trying to show off. It's a disheartening experience to want to use such fashionable concepts as 'objects' only to be told that the way things are done is procedural programming with SQL queries nested in markup like it's 2000 again. In my experience it's been because they've not wanted to invest in learning new things. That's not a good ethos for a programmer. Let's not promote it.

Re: You Should Write Ugly Code

#16
Maintainability and technical debt are very real metrics. It is just question of short-term versus long-term investment. This article prefers short-term investment (as many other startups do). I just wish buyers would include code maintenance costs when evaluating start-up.

Re: You Should Write Ugly Code

#17
post #9

Earlier quoted context omitted.

In my experience, "good" code and "pretty" code are the same thing - and similarly for "bad" and "ugly". Of course, when I say "pretty", I mean well laid-out, properly documented, non-spaghetti code. I've spent far too much of my time tearing out thousands of lines of "bad" code that wasn't written in a way to allow for easy changes.

My issue is the phrase "sake of beauty." This ignores why this code was written. I'm fine with beautiful code. My issue is the use of the word beautiful in such a way as to imply that beauty was the intent. People don't try to write beautiful code, people try to write good code. That it happens to be "beautiful" is a bonus. Hopefully my point is clear. I guess it's subtle, but I think a crucial difference.

I actually thought the article would be about indention, style, etc.

Re: You Should Write Ugly Code

#19
post #10

Earlier quoted context omitted.

Actually, I find that it's usually when the ugly code starts to cost them more. Basically, it's a car without brakes. It will get you where you are going, but it would have cost less all together if you'd installed working breaks from the beginning.

To use your analogy, is it better to have a car with no brakes now, or to save up for another year to buy a car with brakes? The problem with the analogy is that it's _obvious_ that you should save up another year because of the danger. But in startup-world, it's not obvious at all. To really abuse your analogy, if you're being chased by wild hungry bears, you don't care whether the car has brakes.

Brakes generally aren't expensive (obviously, this is all relative... but lets ignore that), so instead of waiting a year, your more likely waiting a few days at most.

The cost of good quality code isn't expensive either, in the short term or even in the long term. However, for the un-or-misinformed, writing good code might seem higher. Indeed, I'll even go so far as to say that for less skilled individuals, good quality code might seem to increase the cost dramatically.

> if you're being chased by wild hungry bears, you don't care whether the car has brakes.

A little planning would mean I wouldn't be in that situation: bears and no brakes. Though, it's amusing coming up with ways I could find myself in that position. =)

Re: You Should Write Ugly Code

#20
If you are writing code for aesthetic purposes of course you are doing it wrong. If you are writing code and balancing delivering features with maintainability. A balance that constantly changes. Then I would argue you are doing it right. Sometimes that balance is just deliver for the deadline, nothing else matters. Sometimes it is this needs to be extensible and maintainable because it's a cornerstone of our product.
Post reply on HN