Live data from Hacker News

Good code is like a love letter to the next developer who will maintain it

addyosmani.com

191–200 of 274 posts

Re: Good code is like a love letter to the next developer who will maintain it

#191

1) "Code sober, debug drunk" It's harder to read the code than to write it so if you can barely comprehend the thing you just wrote, you probably won't understand it in the future: https://sonnet.io/posts/code-sober-debug-drunk/ 2) I think it's more like speaking with ghosts (including a spoiler for The Sixth Sense): https://sonnet.io/posts/emotive-conjugation/

>it’s harder to read code that to write it Isn’t this only true of bad code? Good code is almost certainly the other way round, harder to write than read… just like a really good book was much harder for the author than it was for you, the reader.

I agree with the sibling comment.

> just like a really good book was much harder for the author than it was for you, the reader.

Now, I suppose this could work for a nested narrative novel, where the reader is meant not to just read the book, but to rewrite and expand it as they're reading it. Adding new ideas, new sub stories on the way. Think 100 Years of Solitude blended with Italo Calvino's Invisible Cities.

Seems like the [*]Bible is a good literary example of an async collaboration similar to code: notoriously hard to interpret, and full of dubious historical information and contradictions.

I know that Christians call it the "good book", but most of them don't use the word "good" in the same way they'd use it to describe a Nabokov or Eco novel.

[*] or most ancient religious texts, like Avesta

Re: Good code is like a love letter to the next developer who will maintain it

#192
post #12

Sorry next developer, I'm on a tight deadline, used to love this craft, now I just do what the product people tell me to get a nice paycheck.

Yep. Yesterday I ran into a job opening asking for "Java developer who delivers 3x faster than the other developers" in one of the bullet points. It's such a weird point to emphasize that you want speed with no concern to trade-offs, and the maintainability and scalability of the codebase will be the first victims sooner or later.

I like those offers, they self-identify as places to avoid

Re: Good code is like a love letter to the next developer who will maintain it

#193
post #173

Earlier quoted context omitted.

I too have met many developers who have developed the mindset that good code is impossible. That is really sad. Imagine a carpenter that says straight cuts aren't possible, just because they never maintained their tools and the last 10 cuts came out wrong. Of course good code is possible. But not every person is going to write it and it is not going to happen under all possible circumstances and in all given project…

Now imagine a carpenter who can build the most beautiful, elegant piece of furniture in 30 days, but you force them to make it in 10. Or you forbid them from using a certain tool. Or force them to use a tool you prefer. Or … Yes, not every programmer cares about good code. But of those that do, also not all of them can agree on what good code is. And not all good programmers can write good code, for one reason or ano…

I am not denying that at all. I know my share of carpenters and if they are in a pickle, they might take on a job like that, and swear about it like there is no tomorrow all the way to the bank.

What I found remarkable wasn't that there are badly managed projects, but that there are software devs who seem to think there is no other way than doing it like that.

Re: Good code is like a love letter to the next developer who will maintain it

#195
> Good code also adheres to established best practices, [...]

Controversial opinion, but in my experience so far people usually say "this is best practice" as a way to avoid thinking, or to masquerade personal preferences. Not always, but more often than not.

As soon as you ask "why is it a best practice?", "what are the consequences of not following this best practice?", "since 'best' implies there's a 'not-best', what is an example of the 'not-best practice' that this wants us to avoid doing?".

The answer is usually something vague and handwavy like "because it's more scalable", but if you challenge that by saying "what do you mean with 'scalable'? can you give an example?", you usually won't get an answer.

Doing stuff without understanding the reason, that's cargo cult.

To be clear, I have nothing against people saying "I understand the code better like this"; it's subjective but honest, and it doesn't try to pass a subjective argument as if it were an objective truth. What I dislike is people saying "this is best practice" like an absolute truth that must be blindly followed and never challenged, without even considering the circumstances of the current project.

Please spare me from turning a simple HTTP CRUD of 4 endpoints into an overkill Icosahedronal Architecture with a reason like "when we need to write an v2 this will make it easier without needing a rewrite!"; because I know that when the time comes for an v2 you'll rewrite from scratch anyway because then you'll want to use the new and better(tm) Perpendicular Riemann Zeta Architecture.

Re: Good code is like a love letter to the next developer who will maintain it

#196
I don't think being so romantic helps much. To take these articles seriously is to believe that there is such a thing as good code. but I don't think there is a good code that will make everyone happy. I understand the effort it takes to make the code something permanent, but I think the code has to be something that has changeable and the processes have to adapt.

Re: Good code is like a love letter to the next developer who will maintain it

#197
post #62
post #12

Sorry next developer, I'm on a tight deadline, used to love this craft, now I just do what the product people tell me to get a nice paycheck.

The craft is not the code, but the product. You can have beautiful code and garbage product, and great code and a garbage product. If your PM is pushing bad products, that's on them. Your job is to deliver good product, not good code.

It's true that the product should take priority over the code, but there's a limit to by how much. If the code is bad enough, its low performance, bugginess, and slow feature development will eventually be reflected in the product.

Re: Good code is like a love letter to the next developer who will maintain it

#198

> Good code also adheres to established best practices, [...] Controversial opinion, but in my experience so far people usually say "this is best practice" as a way to avoid thinking, or to masquerade personal preferences. Not always, but more often than not. As soon as you ask "why is it a best practice?", "what are the consequences of not following this best practice?", "since 'best' implies there's a 'not-best', w…

I understand the spirit of your comment here, but in my area of experience, security, there are certainly objective “best practices”.

There is almost always pushback on security considerations, and partly because those methods quite often change and improve with time.

The term then becomes a blanket phrase that captures the constantly evolving landscape and necessity of accepting those new changes.

You’re right that it is becoming over used. Like most abridged language, once your favorite becomes popular a new way to express the same underlying idea usually comes along.

Re: Good code is like a love letter to the next developer who will maintain it

#199
Here are my 2 cents, after 25 years of development in several companies. If you want to do the next developer a favor, your codebase should be simple to understand. Period, that's it. Simple to understand means:

1. Don't use fancy design patterns, FP constructs, performance optimizations etc. Unless the use case specifically requires it.

2. Code should do whatever it needs to do to fulfill its business requirements. Nothing less and preferably also nothing more.

3. Readable code beats documentation: only document the 'why', and only when it is non obvious. If you find you're documenting the 'how', have a second look if you can write your code in such a way that it explains itself.

4. Explain how to build the project, run tests and whatever else is non obvious in a Readme file in your project. Documentation anywhere else, such as on Confluence, will not be maintained or read.

Re: Good code is like a love letter to the next developer who will maintain it

#200
> (...) and the practice of Test-Driven Development (TDD) are indicators of a carefully crafted 'love letter'.

I call BS on this one. TDD is usually a sign of a struggling junior and results in the worst code quality possible.

Also, the next developer is in many cases myself, months later, trying to fix something or adding a new feature. I wouldn't care about other developers, because everyone has their own style and niggles, it is enough to cater to my own niggles, can't be bothered about others. And I also don't make a fuss about code written by others, as long as it meets some minimal standards.

Post reply on HN