Live data from Hacker News

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

news.ycombinator.com

71–80 of 216 posts

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

#75
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.

Please send me your juniors, I'd like to hire them.

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

#77
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…

"maintainable" code is disposable. Modern web stacks are built on the idea that you can delete a file and re-implement its interface with a different service behind it later on. Instead of writing code which will be easy to modify, write a good interface which solves your problems in a way that's easy to reason about, and feel free to write garbage implementations that will get "refactored" (thrown away) every year or so

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

#79
I learned a ton about Java and pragmatic algorithm development from reading Dagger (https://github.com/square/dagger) and porting it to C#. It's small enough that you can grok it in a reasonable amount of time, but sophisticated enough that there's a lot to learn. (Yes it's deprecated in favor of Dagger 2, but the latter is a tougher slog IMO)

Actually most of the big Square OSS libraries are great to read - okio, okhttp, picasso.

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

#80
post #35
post #27

Earlier quoted context omitted.

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 cod…

> Don't copy and paste the same implementation x times because that way there's only one place to fix it.

But also sometimes it makes more sense to copy and paste over trying to fit an abstraction where it shouldn't be. :)

I think the purpose of questions like the ones by OP is not to figure out "rules" (which are useful only for beginners) but to figure out where and why rules were broken. Sometimes (often) the answer is time, but that in and of itself is a useful example.

Good intermediate (I suppose Sr. in our industry) level code is notoriously difficult to find examples of and mentor toward.

Post reply on HN