What Makes good Quality Code?

What Makes good Quality Code?

There are a number of interesting comments in this thread about how to define quality code. I was reading through them and I think every single one of them could be summarized like this:

good quality code is code that make it easy for developers to add value

Every comment in there was some variation of this. There were many different approaches to how you can make code that does this. Some say you need unit tests. Some say it needs to be readable. Some say it needs good structure. Others say it needs to be designed to guide developers to do that right thing, and still others that it needs to be extensible. All of these seems to me like they might be good approaches to achieving the goal, but at the end of the day they all boil down to different theories on how to make code that enables developers to easily add value

I was thinking about this a bit and I think framing it in this way can actually help us come up with strategies for making good quality code. When we frame it in terms of making it easy to add value, it seems to me the next question is how does this particular code base add value? That of course pulls us into the business context the code operates in and supports. Thinking about that has a huge effect on what we would consider to be good quality code.

For example, I’ve written code that was not very well structured and modular before, but I would say it was still good quality code.  It saved me some time in writing reports, but it was code that was only for my use and it was small enough that I could remember what it did and easily tweak when I needed to. It was limited enough in it’s scope (and only had one user: me) that I could very easily test that it worked after changes. It was easy for me to add value with that code and since I was the only one who needed to change it, it was good quality code.

Now in many large scale systems with multiple developers working on it, the approaches I took to that script would have produced very low quality code (i.e code that made it hard for developers to add value). Understanding how your code is going to add value helps along to path towards figuring out how to make your code good quality.  I think when we start to divorce quality from value we end up in trouble.

Good quality code makes it easy to add value. How does the code you work on add value?  What things do you need to do to make sure it is easy for developers to continue to add (more) value?