Live data from Hacker News

There's no shame in code that is simply "good enough"

blog.phiz.net

11–20 of 68 posts

Re: There's no shame in code that is simply "good enough"

#11
This actually causes "coder's block" in me when I start a new project. If I have this cool app or site idea, it often never gets off the ground because I spend too much time trying to create some architectural framework that I assume I need.

This is REALLY bad for me in Cocoa/Cocoa Touch apps. Objective-C is so verbose and writing classes is so "mechanically cumbersome" (having to write .h and .m files and duplicate stuff, for example) that I sometimes lose interest before I ever really get off the ground.

The trick I use to beat this tendency is to totally eschew good software engineering principles at first. Typically all of my code lives in main.m (and I usually start out in CodeRunner rather than XCode). Interfaces are done sloppily in Interface Builder or entirely in code. This really helps me get started.

Before long, of course, I have this unwieldy spaghettified mess of a single source file. By that time, though, I have some stuff WORKING, so doing some refactoring into a good architecture for the code I have while keeping the working stuff working is kind of fun.

Re: There's no shame in code that is simply "good enough"

#12

This actually causes "coder's block" in me when I start a new project. If I have this cool app or site idea, it often never gets off the ground because I spend too much time trying to create some architectural framework that I assume I need. This is REALLY bad for me in Cocoa/Cocoa Touch apps. Objective-C is so verbose and writing classes is so "mechanically cumbersome" (having to write .h and .m files and duplicate…

I find that the limited free time (wife, kids, etc.) I have available for side projects forces me to prioritize. If I gold-plate everything, nothing will ever get done, so I simply don't write code that's not absolutely necessary.

I will code very thin "frameworks" if it becomes obvious that it will save time over the long haul, but there is no "this might be useful someday" code. If it doesn't move the project forward, it doesn't get done.

If your most precious resource -- time -- is limited, it forces ruthless prioritization.

Re: There's no shame in code that is simply "good enough"

#13
"Perfect is the enemy of good enough; good enough is the enemy of all." [1]

There's no shame in code that's 'good enough' but I think there's a danger in this article of missing an important point: you can't classify your output if you don't know its context and goals. If you're coding something that definitely won't be used again then make it 'good enough' for this use case, if you need it to be extended by others over the next few months then make it 'good enough' for that use case, if you have a contractual obligation to get it out to the client 'now' then stop thinking and start doing!

But paralysis is costly. If you lack the required knowledge to take a sensible decision, then take a gamble: never hold up making a low-risk choice because you don't know enough. The opportune time to learn what the right choice was is once you've made it and can evaluate the outcome with data.

The other thing to note is that complexity on its own isn't bad, complicatedness is [2]. The knowledge you've gained shouldn't be making your code more complicated. You should spend your time on creating an arsenal of simple solutions to complex problems. That is perfection (and you will never reach it.)

Optimize your time by evaluating after instead of planning before; over time create simple solutions to complex problems and use these as shortcuts to act decisively.

[1] http://paulbuchheit.blogspot.com/2007/04/perfect-is-enemy-of...

[2] http://usabilityworks.org/2006/12/13/simplicity-complexity-a...

Re: There's no shame in code that is simply "good enough"

#14
The key I've found is not worrying about how beautiful or clever the code is, but how maintainable it is.

If the code is designed properly, the only requirement I have is that I can go back into my code and change it easily to what I now need it to do. It should be malleable like silly putty. If I can do that easily, without requiring massive rewrites, then this means that the code can change as my requirements change, and that to me is a good design, and "good enough" code. So don't worry about optimizing too early, but make sure the code can be optimized easily when you need it to be.

If I want to make code changes that requires massive rewrites when my requirements change a little, then it means I've coded myself into a corner, and I've done a poor job designing the code.

Re: There's no shame in code that is simply "good enough"

#15

one way to think about this is code as a "consumable" instead of as a "durable" good. There is an essential difference between a paper cup and a glass. Say you are throwing two outdoor parties a year, but otherwise will not serve more than 8 people. The best solution, if you start with nothing, is to buy a set of dishware for 8, and then throwaway plastic cups and plastic knives twice a year ad hoc. Code could be see…

> Say you are throwing two outdoor parties a year, but otherwise will not serve more than 8 people. The best solution, if you start with nothing, is to buy a set of dishware for 8, and then throwaway plastic cups and plastic knives twice a year ad hoc.

Not really. Only if you've no time to look for good dishware (surprise party?), can't afford it this instant (or fall in the common pit of not doing the math for the long term) or you absolutely do not have space for the “extras”, which is fairly rare.

To extend the metaphor, this “disposable” code tends to end up in unexpected places and stick around polluting the ecosystem forever.

Or, like some people, using disposable stuff every day and probably having trash all over the house to show for it.

That said, disposable code is fine. The metaphor isn't exact, but does point to some things to be cautious of.

Re: There's no shame in code that is simply "good enough"

#16
Always keep in mind the great Larry Wall quote:

"Always write code as though it will be maintained by a homicidal, axe-wielding maniac who knows where you live ..."

There are two ways to write poorly maintainable code. One is poorly organized spaghetti code and the other is overly architected code.

Larry Wall also once said, "a programmer can write in assembly using any language."

Re: There's no shame in code that is simply "good enough"

#17
It's a nonstandard definition of optimization in many of these case but I still feel like this all falls under "Premature optimization is the root of all evil"

Also importantly apparently the full(er) quote is "say about 97% of the time, premature..." Because even Knuth knew that sometimes you should design for that herd of buses.

Re: There's no shame in code that is simply "good enough"

#18
post #16

Always keep in mind the great Larry Wall quote: "Always write code as though it will be maintained by a homicidal, axe-wielding maniac who knows where you live ..." There are two ways to write poorly maintainable code. One is poorly organized spaghetti code and the other is overly architected code. Larry Wall also once said, "a programmer can write in assembly using any language."

Never realised Larry Wall was a Young Ones fan.

Re: There's no shame in code that is simply "good enough"

#19
I still experience the drive to "over-architect" a solution every so often, especially when starting a new project. For me, it tends to be a result of thinking, "oh, I can add that additional feature with little impact to the timeline of the project." I have to force myself to remember the mantra: You're Not Gonna Need It. More often than not it ends up being right.

http://c2.com/cgi/wiki?YouArentGonnaNeedIt

Re: There's no shame in code that is simply "good enough"

#20
post #13

"Perfect is the enemy of good enough; good enough is the enemy of all." [1] There's no shame in code that's 'good enough' but I think there's a danger in this article of missing an important point: you can't classify your output if you don't know its context and goals. If you're coding something that definitely won't be used again then make it 'good enough' for this use case, if you need it to be extended by others o…

I was confused about your point until I clicked the first reference. You made a slight misquote that change the whole quote.

Good enough is the enemy of at all.

Post reply on HN