Live data from Hacker News

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

news.ycombinator.com

61–70 of 97 posts

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

#61

Assuming you mean programming professionally (i.e. most of every day), then five years is around the point where you become self-aware and realize your code isn't as awesome as you thought. Also, remember that if you see code published on the Internet, it was probably extremely polished, and likely written by someone who has had quite a lot of experience in a particular area. By having to maintain my code, I learned…

The third iteration thing is exactly what I was thinking when I read this thread. First attempt works, but it's pretty shoddy. Do it again and you get something better but still has room for improvement. By the third it's still not perfect but it's good enough to make you happy you did a good job.

My other benchmark of bad code is that you know it's bad when you have to hack it to add a new feature, and the only way to remedy that is to re-factor most, if not all, of your codebase.

I've had to do this a lot lately because I've not had chance to iterate. I know full well the code is bad. It works but it's not easily maintainable, and since it's in the context of a REST API there's a shitload of code we now have to duplicate - with minor differences - to add functionality I didn't have the foresight to plan from the start.

That of course is also the side effect of being given an entire project to do by yourself while the rest of your team does other things. The insight and assistance from colleagues or team-mates, or even friends if it comes to it, is just as valuable for writing good code. Knowledge has to come from somewhere.

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

#62
post #30

Assuming you mean programming professionally (i.e. most of every day), then five years is around the point where you become self-aware and realize your code isn't as awesome as you thought. Also, remember that if you see code published on the Internet, it was probably extremely polished, and likely written by someone who has had quite a lot of experience in a particular area. By having to maintain my code, I learned…

+1 for the having to maintain your own code. I remember looking back at my own code and swearing "what the *$$# was i thinking.."

I know what I was thinking most of the time: I want to get this thing working and out there as quickly as possible.

Deadlines are probably the root cause of most of the world's most horrific hacks.

Also, I've never once had a boss turn to me and say "you know what, forget about writing any new features for now - just refactor the code that is working just fine but looks horrible."

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

#63
After a little over ten years of daily full-time coding, I'm finally at the point where I can go back to code I wrote three or six months ago and not think, WTF? I'm by no means a great programmer, certainly not compared to some of the brilliant coders on HN, with whose work I'm constantly inspired and humbled; but as Dirty Harry famously said, "A man's got to know his limitations," and I think I'm pretty realistic in that regard.

To get better: keep noticing your mistakes and taking them into account on subsequent activities; keep modifying your workflow to incorporate and automate good practices and to remove the potential for preventable mistakes; keep taking opportunities to clean and refactor old code when you have to face it; keep reading other people's code (especially those brilliant coders kicking around HN) and learning from it; and keep pushing yourself to get better. Rinse and repeat for as long as you spend programming.

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

#64
post #21

If you're using it for a start-up - it's much more important to deliver usable software than quality code - you can always go back and clean up the code - but if you don't get traction it's all over. Also - consider buying code reviews from developers you respect - even a couple of hours a week can make significant difference to your quality.

I'm currently working on a startup and like the OP I was questioning how good of a programmer I am. I'm self taught and have been programming since I was in middle school computer club more than 8 years ago.

Working on this startup project has taught me that in the beginning it's all about delivering a product that works that users want. When requirements are constantly in flux and you're working hard and fast to develop a fully functional prototype there's little time for code refactoring to make it "perfect" because the longer it takes to launch the larger the possibility that someone beats you to it. As long as the code does what it's supposed to do and is not loaded with bugs and isn't terribly slow I say to just go with it.

Requirements are always changing in startup land and a good programmer adapts to make those changes and is focused on producing a workable prototype before their competition does

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

#65
Disclaimer: I have like 6 years of experience, I'm not a famous programmer, but I do get people telling me (more than 20 programmers) that I'm a good programmer and I write good code.

Read code, watch people coding, care about your tools, and finally, your code will never be "good enough" you'll always improve.

Read code: Read open source software, from the libraries and frameworks you use for example; That way you'll learn new techniques and ways to organize your code so it's more readable. Also it helps reading books like Code Complete and Beautiful Code. I recommend "Framework Design Guidelines: Conventions, Idioms, and Patterns for Reusable .NET Libraries" even though I'm not a .NET programmer I really like that book.

Watch other people coding: Get together with friends to pair program, or online, most people like to pair program. Or watch some of the new Peepcode videos on experts programming (https://peepcode.com/screencasts).

Care about your tools: Now that a lot of people are using dynamic languages I see it over and over again, people just use whatever editor, debugger, etc etc, care about those things, you'd rarely see myself making a "unused variable" mistake, because I have all the linting tools, and I follow them, same goes to code formatters, etc etc, I recommend VIM to edit code, Git as a communication tool (which is version control), Chrome as debugger. Also try the best way you can to reuse things, framework like Backbone, Batman, Knockout helps a lot with your JavaScript, never use just raw jQuery, it's not needed anymore.

You're never gonna be good enough, there's always gonna be a DHH, Jacob Kaplan Moss, Jeremy Ashkenas (just to name a few) to look up to.

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

#66
post #31

If it solves the business problem your clients are paying you to help them with, your code is definitely good enough. The people with opinions about your code are probably not paying you. So coding well is more like being polite to them. Really good code makes their lives slightly easier than average code (which is way better than no code). But politeness goes both ways. If they see you trying to improve, they'll pro…

"Do whatever it takes to solve the business problem now and we'll worry about the other stuff later" is what produces horribly complex code bases because "later" never comes and management will never justify the time to fix things. This presents you with a number of problems: * It makes it harder to pivot in the future. You may end up having to rewrite a lot in order to extend the original model. * In most cases, thi…

I assumed OP was competent but not stellar, so my answer was about the difference between average and good.

You're talking about bad. I agree that no competent programmer would do the things you're describing if they could possibly help it. So we probably would have given OP the same advice if we had started with the same assumptions.

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

#67
there's an art to writing readable and reusable code, but you have to start by understanding the problem.

when you really understand the problem, the problem and surrounding use-cases become obvious. when this happens, writing readable code becomes trivial, as long as you understand what tools you need to use to solve it.

sometimes the right tool is a library, sometimes it's adapting existing code, and sometimes it's a special language construct like Python metaclasses.

whatever your problem, try to describe it and the solution in english at a high level. then, how can you best fit your solution into the mental framework that you just created?

as for reusable code, just be aware of leaky abstractions and complexity. often times i see libraries that introduce more complexity into a program than needed, sometimes because the solution doesn't really fit into a module. often times the solution is another language, like jQuery or Haml.

anyways.

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

#69
I have never believed in beautiful code. That is like saying there is a beautiful spanner or crescent wrench. Save the beauty talk for the Rembrandt and Monet. I pursue two things in my code Clarity, relentless reliability and simplicity. Clarity because I am like the girl from 50 first dates I not going to remember it tomorrow so it better be clear enough that someone(me) will be able to figure it out without to much trouble.

Relentless simplicity, if making your software a little simpler to use means that its 1 million users have to remember 1 less thing because you have remembered 1 more thing then you have just saved 999,999 brain cells.

Relentless reliability is rather similar to relentless simplicity it should work the same way every time all the time. Any time you break the guaranty of getting it done right you just cost a lot of thought and effort for a large number of people.

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

#70
post #30

Earlier quoted context omitted.

+1 for the having to maintain your own code. I remember looking back at my own code and swearing "what the *$$# was i thinking.."

I know what I was thinking most of the time: I want to get this thing working and out there as quickly as possible. Deadlines are probably the root cause of most of the world's most horrific hacks. Also, I've never once had a boss turn to me and say "you know what, forget about writing any new features for now - just refactor the code that is working just fine but looks horrible."

>Deadlines are probably the root cause of most of the world's most horrific hacks.

I definitely agree with this. I've written some absolutely terrible code in marathon sessions with an impending deadline -- in the worst case, I copy-pasted code in six or seven locations for something that could have and definitely should have been factored out into a function. I just didn't have any time to spare, I had to finish it for a demo in X hours. That whole project was a mess.

Post reply on HN