Live data from Hacker News

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

addyosmani.com

61–70 of 274 posts

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

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

good code is like vintage wine: you don’t recognise the packaging, no-one agrees on how exactly to describe why it’s good, and the only person who still remembers all the details of production retired ten years ago

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

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

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

#64
post #40
post #3

And remember, the next maintainer could very well be you.

When I do personal projects for myself, I try to comment them really well for this exact reason. Just today in fact I was trying to update some code I wrote two years ago because one of the underlying tools broke. I was very happy with past me for commenting the workflow of that tool so I could easily work around it.

A good alternative is code without comments that communicates just as well as that code without the comments. Not necessarily better but less likely to slip out of sync with the comments upon change.

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

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

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

This applies to artistic endevours like books and paintings as well (especially those two, since markets for them are very oversaturated). Your technique might be masterful, but if your art doesn't align with current trends (along with a number of other factors), it'll drown in the endless barrage of other art, and nobody will stumble upon it or pick it up, even if it's still available.

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

#66

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

Style changes over time, but factoring is evergreen.

Something could be written using Java 1.4 idioms with good organization and factoring, or using the latest functional hoohas with everything all mashed together. Or the inverse, of course.

If the structure of the code matches the structure of the problem, the implementation style is a much smaller deal.

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

#67
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

metaphors are like, herding .. fine old .. elephants .. in the air

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

#68

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

I think about this all the time when it comes to evolving systems. I work on a programming language, and these tensions are core to my job. In the context of a language, I think it can be:

* Modern, where the language's features and idioms reflect the best way we know to write good, clean code today.

* Compatible, where code written in the language years ago continues to run the same as when first written.

* Simple, where the language has relatively few concepts that compose in clean ways and where there are few ways to accomplish the same goal.

But you only get to pick two.

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

#69
The emphasis on tests made me laugh: I work on a project where it's mandated that all the code is covered by Unit Tests. In my estimate the time to make UT is 3* the time to create the code. And no, nobody use TDD in this project because it takes 3 minutes to compile one UT (C++ sigh), so we all do 'post coding' tests. While sometimes the UTs do help, they're also a huge burden: wants to fix some code? Well you also have to update the UTs..

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

#70

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

> there is no such thing as good code

definitely not true. this is good code:

https://github.com/torvalds/linux/blob/master/fs/file.c

this is good code:

https://github.com/golang/go/blob/master/src/strconv/atoc.go

its formatted, commented, direct. the fact that you struggle with writing time tested code does not mean that everyone does.

Post reply on HN