Live data from Hacker News

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

addyosmani.com

51–60 of 274 posts

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

#51
post #26

I prefer the quote that goes "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live."

This. I was about to mention the same quote. This quote alone has served me well over the years. Sounds jokey but if you live by this, it’s brilliant.

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

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

There are cases where the tradeoffs don't involve the actual codebase. For instance, there are certainly many developers who are 3x faster than the average developer simply as the result of having enough experience and/or skill to know which tools and/or approaches are optimal for a large subset of the kinds of problems they encounter in their typical work, such as a developer familiar with a particular ecosystem accomplishing some task in 10 minutes by knowing which library and which function to use, and how, whereas another might take hours (or days) to accomplish the same task since they have to figure out what tools are even available to solve an issue and how to use them, or worse (sometimes), rolling their own solution where a library implementing the functionality already exists. The tradeoff here is simply that it will be harder to find such developers, and they'll generally want higher compensation, but their work will not degrade the quality of the codebase, quite the opposite.

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

#55
post #20
post #15

In my opinion, good code is like a Brita filter. It does its job, will one day need to be replaced, and it should be easy to replace. More importantly: metaphors are not a healthy way to understand an idea. Ideas are more nuanced than a metaphor could possibly account for. Abstaining from metaphors might not make for a catchy headline though.

Little pushback here - metaphors are great tool to understand something, and can convey some meaning more efficiently than other means. But "the map is not the territory"!

The territory isn't the territory either, so no big deal!

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

#56
post #15

In my opinion, good code is like a Brita filter. It does its job, will one day need to be replaced, and it should be easy to replace. More importantly: metaphors are not a healthy way to understand an idea. Ideas are more nuanced than a metaphor could possibly account for. Abstaining from metaphors might not make for a catchy headline though.

Metaphors are also ways of communicating ideas. A good metaphor is as simple or as complicated as it needs to be in illustrating a new concept

Problems arise as soon as you (ab)use a metaphor (used to explain a higher level/adjacent problem) to explain concepts it was never meant to model.

Example: Array of items as a shopping cart: how do you efficiently remove an item from the array (as you can from a shopping cart)?

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

#57
As someone who has gone back and read my old code as well as a lot of others old code, there is no such thing as good code. IMHO, the problem is one of cultural context which is often not shared between generations of coders. Languages and best practices can change so violently that best-practices one decade are often anti-patterns in the next.

As a codebase outlives its best-practices, do you stick with them and extend with those same anti-patterns or do you implement new things with a different mindset than the rest of the code?

  -- If you break with tradition then you are making it harder to understand the codebase as a whole.
  eg: why do we have a mix of procedural/OO/functional/... methodologies with spaghetti code at the core?

  -- If you refactor everything then you are definitely breaking something.
  eg: you have a 10M+ line java codebase with transformations bringing you into the 2020s from coders who originally knew C and Java 1.4.

  -- If you keep with tradition then are you writing the best code possible?
  eg: would you willingly use goto of some variant in new code if you jumped into a Cobol 74 codebase?
I think what the article really wants to talk about is "clear" code or "understandable" code and not "good" code.

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

#59
post #32

Good code is not like art, such as good books or paintings. No matter the quality of your code, if the product or service is not a good market fit. It will be retired. No one will stumble upon it or pick it up after it's gone. Knowing this, the only reason for putting effort into it is to make it easier for myself.

The two aren’t always mutually exclusive, you might be writing code for a good market fit that stands the test of time and needs maintaining.

The times you appreciate it are actually when you open something and it’s nice and easy to change and you realise you were the one who wrote it. But real developer happiness comes when you have the same experience and someone else wrote it.

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

#60
After more than a decade of development, I've come up with this mindset:

I don't really care that much about the developer, and care a lot more about the users of my product, especially since that developer is usually me.

If I'm unsure of the value I'm adding, or if the ability to do something is greater than its quality, I will take shortcuts if needed.

If the codepath is critical, or if doing so is dangerous, I will take my time on the quality and the foolproofness. I will be pertinacious in this mindset, and if managers try to rush me, I will remind them of the consequences of failure and log everything.

I've seen too many developers (myself included) spending weeks and months on perfecting something that's never used, or barely used. The latter issue of not spending enough time is a lot more rare, but does happen.

Post reply on HN