Live data from Hacker News

Ask HN: Where do I find good code to read?

news.ycombinator.com

31–40 of 216 posts

Re: Ask HN: Where do I find good code to read?

#31
post #17

Give up on “good code”. Its pursuit is how junior devs pesters senior devs based on a delusion that such a thing is possible. Good code is working code, code that pays the bills. Focus instead on writing code you can throw away easily, code that you are wholly unattached to and is isolated enough that rewriting it won’t cost absurd hours.

Taken at face value, this advice is probably just as bad as the opposite ("write perfect extensible modular code with 100% documentation and test coverage"). There is a lot of room in between where the enlightened developer can find happiness.

You misunderstand; nothing about what I suggest says you shouldn’t write, “perfect extensible modular code with dull documentation and tests.”

If that’s what you need to do to solve the problem, do that. The point is to stop focusing on the code as the work product, and instead focus on the solution as the work product, of which code is one part.

Re: Ask HN: Where do I find good code to read?

#33

I really like the go standard library. It's all really clear and easy to understand https://cs.opensource.google/go/go/+/refs/tags/go1.21.0:src/... https://cs.opensource.google/go/go/+/refs/tags/go1.21.0:src/...

Was about to comment the same thing. Highly recommend.

Re: Ask HN: Where do I find good code to read?

#34
post #17

Give up on “good code”. Its pursuit is how junior devs pesters senior devs based on a delusion that such a thing is possible. Good code is working code, code that pays the bills. Focus instead on writing code you can throw away easily, code that you are wholly unattached to and is isolated enough that rewriting it won’t cost absurd hours.

Good code "is isolated enough that rewriting it won’t cost absurd hours." This is the hard part.

Re: Ask HN: Where do I find good code to read?

#35
post #27
post #17

Give up on “good code”. Its pursuit is how junior devs pesters senior devs based on a delusion that such a thing is possible. Good code is working code, code that pays the bills. Focus instead on writing code you can throw away easily, code that you are wholly unattached to and is isolated enough that rewriting it won’t cost absurd hours.

I disagree. The problem with believing that "good code" is good enough to deliver business value is short-sighted. Good code is highly maintainable so that you can continue to meet business objectives in a timely manner without regressions. Often this means (ironically) taking a little bit of extra time early on to think about how to make your code readable and "simple enough" for someone else to be able to jump in a…

> Focus instead on writing code you can throw away easily, code that you are wholly unattached to and is isolated enough that rewriting it won’t cost absurd hours.

> Good code is highly maintainable so that you can continue to meet business objectives in a timely manner without regressions.

I think you essentially agree on what people should do, regardless of whether you call this 'good code' or just maintainable code.

Write tests. Give things good names. Use comments to explain why you're doing something, not how to program. Don't copy and paste the same implementation x times because that way there's only one place to fix it.

Re: Ask HN: Where do I find good code to read?

#36
post #17

Give up on “good code”. Its pursuit is how junior devs pesters senior devs based on a delusion that such a thing is possible. Good code is working code, code that pays the bills. Focus instead on writing code you can throw away easily, code that you are wholly unattached to and is isolated enough that rewriting it won’t cost absurd hours.

"write code that is easy to throw away" is generally a good piece of advice

Re: Ask HN: Where do I find good code to read?

#37
post #20

This isn't exactly a repo to look at, but the book "Clean Code" is a fantastic read for learning how to write good code. It does have a lot of examples in it, and does a great job explaining everything. https://github.com/jnguyen095/clean-code/blob/master/Clean.C...

https://qntm.org/clean has a great discussion of all the things that are wrong with Clean Code.

Interesting read. I read a companion book (or is it wholly unrelated?) called Clean Code for Python and I learned a whole lot! That book improved my Python more than anything else, honestly. That being said, I agree with the critique that obsessively committing to DRY is throwing the baby out with the bathwater.

Re: Ask HN: Where do I find good code to read?

#38
post #27
post #17

Give up on “good code”. Its pursuit is how junior devs pesters senior devs based on a delusion that such a thing is possible. Good code is working code, code that pays the bills. Focus instead on writing code you can throw away easily, code that you are wholly unattached to and is isolated enough that rewriting it won’t cost absurd hours.

I disagree. The problem with believing that "good code" is good enough to deliver business value is short-sighted. Good code is highly maintainable so that you can continue to meet business objectives in a timely manner without regressions. Often this means (ironically) taking a little bit of extra time early on to think about how to make your code readable and "simple enough" for someone else to be able to jump in a…

The problem with this “maintainability” argument is the presumption a) that it will be maintained (note I recommended rewriting frequently) or that b) it’s in conflict with meeting business objectives.
Post reply on HN