Live data from Hacker News

Ask HN: I think My code isn't Good enough

news.ycombinator.com

81–90 of 97 posts

Re: Ask HN: I think My code isn't Good enough

#81
post #75

First and foremost, write your code so that it can be understood easily by someone that knows nothing about it. As you get older, you'll realize that this person is you! Anything written over 2 weeks ago is often like looking at new code, so make sure you have good comments and non-obscure variable names so that you can understand it easily. This also makes it easier on your coworkers. Second, write for readability a…

Sorry, but actually it sounds like quoted from a (programming) fantasy novel. Look at the other comments, who argue that the nice and clean code is not always the best, not always the goal and sometimes not even a goal that can be achieved. This(!) is what you learn from experience.

I've heard the same thing for 15+ years now. "There's not enough time, I have to check it in." "I'll clean it up before we ship."

The time difference between writing clean code and crappy code is negligible. The main difference I saw was always in the attitude of the programmer. This is what you really learn from experience. There are lots of programmers out there with diva complexes who think it's beneath them to write easy-to-understand code, or love using 1-character variable names, etc.

Sure, maybe there might be situations where you don't have a lot of time, for example, if you are programming algos for HFTs and the traders are standing over you yelling that they need a particular parameter changed and they are losing a thousands of dollars per minute.

But in most other situations, it doesn't take much time to type "ptrCache" vs "ptr1", or add comments so that the next person who reads your code won't be scratching their head wondering wtf you were thinking.

Re: Ask HN: I think My code isn't Good enough

#86
You're definitely not alone in feeling like this. "Good enough" always depends on the circumstances, so the best way to know if your feelings are warranted is to get honest code reviews from the people who will be working with your code. Balance that with external reviews from programmers you look up to (expecting some contradictions) - then take your own path.

Don't despair if you get a lot of negative feedback - it's easy to improve by reading some of the books listed in this thread and repeat.

Enjoy the journey - I've yet to meet I've yet to meet someone who's reached the destination (although plenty have stopped along the way).

Re: Ask HN: I think My code isn't Good enough

#87
Just tonight I had to work on a code base that I initially wrote about five years ago. This is a working product that's been rock-solid for the client. Still though, at one point, I really hated the code.

Nevertheless, I've been able to extend bits and bobs of it over the years without major headache or breakage. And tonight I had to write a simple related utility program. I was able to grab various classes out of the code and just use them, or re-purpose them with little effort.

Are there issues with the code? Hell yes. I'm always learning as a programmer and I'm much better now than I was then. Does that mean the code was crap? It feels kind of hard to say this, but no it wasn't crap. It did the job and it hasn't been a maintenance nightmare.

So when you look at code you wrote 6 years/months/weeks/days/hours/minutes ago and think, that's total crap! Don't beat yourself up over it. It just means that #1 you care and #2 you have learned something between then and now.

Oh, and after looking at the first line of nirvana's post, I thought about it and realized I wrote my first bits of code about 30 years ago too.

Re: Ask HN: I think My code isn't Good enough

#90
post #22

I know my code isn't good enough, and I've been programming for about 30 years! Not only that, my code isn't good enough, but I'm a great programmer. I might be making some wrong assumptions, but I think the people whose code is really bad are the ones who think their code is good enough, or the ones who just code quickly without thinking. (I tend to think quite a bit and then code. In fact for the particular project…

"The unskilled therefore suffer from illusory superiority, rating their ability as above average, much higher than it actually is, while the highly skilled underrate their own abilities, suffering from illusory inferiority." Dunning-Kruger effect, and it is the same in most professions where 'performance' can be a subjective judgement. Teaching, definitely! http://en.wikipedia.org/wiki/Dunning%E2%80%93Kruger_effect

The Dunning Kruger effect is talked about a lot on here.

More recent research casts doubt on their original study. I first heard about this on [Overcoming Bias] where they talk about a 2006 study which showed "on difficult tasks, where there is a negative bias, the worst performers are the most accurate"

[Overcoming Bias]: http://www.overcomingbias.com/2008/11/all-are-unaware.html

Post reply on HN