Live data from Hacker News

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

news.ycombinator.com

31–40 of 97 posts

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

#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, this means no tests.

* Maintenance costs significantly more.

* When you hire new people to work on the code base, it will take a significant amount of time for them to come up to speed and be productive in the code base.

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

#32
post #14

what you think I should do to improve on that Rewrite. Write some code, make sure it works, and then look at places where it's ugly and figure out how to rewrite it so that it's better. You won't write good code the first time, unless you're writing something that's trivial for you (too easy). While the examples are too Java specific, the book Refactoring by Martin Fowler is a terrific introduction to the skill of im…

Someone downvoted this? This seems like good advice to me...

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

#33
post #3

Here's Jeff Atwood's take on it: http://www.codinghorror.com/blog/2009/07/nobody-hates-softwa... "I think you can tell a competent software developer from an incompetent one with a single interview question: 'What's the worst code you've seen recently?' If their answer isn't immediately and without any hesitation [the] two words 'My own.' then you should end the interview immediately."

That's a poor way to judge. I'm always looking at my code and thinking that it's not good enough, but there are definitely pieces of code that are worse that I deal with daily (I work on a code base that's > 20 years old).

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

#34
post #4

You say you have been programming, but not if you are solely a programmer or building a product as well. Perhaps it would be easier to think of code as a medium to achieve a higher goal, which is functional software. I'm inclined to believe that this is more important than "code beauty" which is something highly subjective and tends to be constantly evolving with your experience. Note I am not promoting spaghetti cod…

//Of course this is my view after having spent non-trivial amounts of time making code beautiful, modular and reusable instead of trying to solve the problem at hand.

I can identify with that feeling. working at a startup made me realize that i have spent more time reading code than writing code. While that's not a bad thing on it's own, i had lost sight of the joy from building/improving things/product. I have been programming for 4-5 years now and pissed that i don't have a product of my own(crappy/otherwise).

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

#35
post #33
post #3

Here's Jeff Atwood's take on it: http://www.codinghorror.com/blog/2009/07/nobody-hates-softwa... "I think you can tell a competent software developer from an incompetent one with a single interview question: 'What's the worst code you've seen recently?' If their answer isn't immediately and without any hesitation [the] two words 'My own.' then you should end the interview immediately."

That's a poor way to judge. I'm always looking at my code and thinking that it's not good enough, but there are definitely pieces of code that are worse that I deal with daily (I work on a code base that's > 20 years old).

It's a poor way to judge code, yeah, but the more important thing it speaks to, IMO, is the respect the developer has for the fact that other people will actually be executing the code they write.

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

#36
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 and maintainability. Save optimizations for the last step. If your code is properly modularized (but not OVERLY-modularized) then you'll be able to selectively optimize and get good performance. As you grow as a programmer, you'll realize that having maintainable code (ie. code you can change easily with new features, or changing requirements, etc) with really good performance is far more valuable than terrible code with the fastest solution. Well-written code that is flexible and that you can shape like putty and add features to do what you want is exactly the point of programming.

The one thing you don't want to do is design code and products that become unmaintainable to the point where the costs of adding features becomes a nightmare. This is what I call coding yourself into a corner. I worked on a project where adding a single feature had a 3 page matrix of things that might break, and would need a lot of QA effort to validate. This is not maintainable code, and an example of where every new feature gets exponentially harder to add, which pretty much kills the product.

Third, I think it's great that you don't think your code is good. This means that you care! I would say only 40% of the coders I've come across actually cared about making their code better, or about mastering the art of programming. Just keep on programming, have a thick-skin to code reviews (I gave a code review to a new programmer who burst into tears because she had never been code-reviewed before), and be willing to learn. I have 15+ years of experience, and although I'm comfortable with my own style, I'm very open to criticism and always willing to learn.

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

#37

I felt like this with my code for the first 5 years that I was coding as well. My code now isn't pristine or perfect, but I'm consistently satisfied with the quality of my final products. Here's what I did to get to the point where I'm happy with my code: 1. Debug and refactor. Early on, I'd stumble through creating a script. It was usually write three lines, see if that worked, repeat. I didn't plan ahead enough, an…

I've been trying practice better, as I think we all tend to mostly learn by using or reading documentation.

I started "exercising" a bit before I kick into coding. A few different exercises I made so far:

1. API Memorization: go through an API and try to build something that executes each function once. This is great with a REPL.

2. Reading code: find a sweet, highly regarded open source library, and, well, just pick up a file and read it.

3. Improving tool usage: improve typing speed, memorizing functionality of your editor, etc.

I try to do one exercise for about 30-45 minutes daily (if possible). I write down what I read or memorized in a spreadsheet. Maybe I'm anal.

I see exercises like how sports folk practice, or how musicians (I play the saxophone) do scales, etc. It just kind of rounds ya out a bit. Over time, you just get a little faster.

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

#38
Let's take programming out of the equation with a quote.

"Laws, like sausages, cease to inspire respect in proportion as we know how they are made." - John Godfrey Saxe.

The problem with looking at any recent code that you write is that you know how it was made (i.e.: you are in the kitchen making the sausages). But it's different if you are the customer eating the sausage. Even if the cook told you how the sausages were made, you still don't have first-hand knowledge, so you elide over the means (good or bad) to get to the ends. It's only when you really dig in and start to understand the process you start to see that the people making the same things you make are in the same boat as you.

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

#40
post #35
post #33

Earlier quoted context omitted.

That's a poor way to judge. I'm always looking at my code and thinking that it's not good enough, but there are definitely pieces of code that are worse that I deal with daily (I work on a code base that's > 20 years old).

It's a poor way to judge code, yeah, but the more important thing it speaks to, IMO, is the respect the developer has for the fact that other people will actually be executing the code they write.

So if I've recently seen code that is subjectively worse than the worse code I've ever written and I answer that question honestly, the interview will immediately end? That seems like a poor way to judge a developer.
Post reply on HN