Nick Mudge Ignition Software Consulting & Development

Lately I've been thinking about what good programming is. I don't think good programming is just opinion, but actually a real thing.

I think a lot of programmers don't really understand programming and think good programming is what code meets their latest fad methodology, design pattern, or is written in or is similar to how things are done in their new favorite programming language.

A good set of criteria for good code doesn't include whether it is object oriented, or is written in a functional programming style, or is strongly typed, or dynamic, or is written in one language or another, or uses this tool or that one etc. Code evaluated by such criteria is a matter of opinion. Technologies and methodologies can make it easier to write good code, but it depends on how they are used and what kind of problems they are being used to solve.

It is more important and useful to understand what good code is and aim to write good code, than to know and use a methodology or technology.

It could be said that any code is on a scale of quality with contrasting unattainable absolutes at each end. One end being the most horrible code possible and the other being the best code possible. To place any code on this scale, I'd judge it according to this:

How good code is depends upon how simple, direct, clear, short, correct and expressive it is in solving the problem or implementing the algorithm for which it is written while meeting the speed and efficiency demands required.

This sums it up exactly:

"Make everything as simple as possible, but not simpler." - Albert Einstein

(I have been hesitant to bash certain programming languages/methodologies/technologies because any such technology that can be used to write good code can be a good technology.)

Comments

TheophileEscargot
theophileescargot.hulver.com
7 June 2008

The fundamental test of good programming isn't what the programmer thinks. It's what the users of the software think about it.

It's like sex: you're not necessarily good at it just because you're enjoying yourself. It depends what your partners' experience is.

Sadly, on programming blogs, most of the judgements are either:

"I must be good at it because I'm having a great time."

Or worse:

"I've never actually done it for another human being, but I bet I'd be really good if I did."
Simon Johnson
www.ckwop.me.uk
7 June 2008

I think if you're going to talk about code quality you need to come up with things that are objectively true otherwise you're just going to get in to a flame war.

Here's what I say quality software is:

1. It works. If the program is too buggy then clearly it can not be high quality.
2. It is easy to test. If you can't test it easily how are you sure it works?
3. It is well documented. If if your program has zero bugs but no documentation, how is your user to use it?
4. The program's interface is consistent. A program with a weird UI is hard to learn and frustrating to use.

Simon
Eric Florenzano
www.eflorenzano.com/
7 June 2008

I disagree on the grounds that your description allows for perlish super-concise code (yet direct, simple, short, etc.) which combined with a page full of similar code becomes absolutely unmanageable.

I think we can't define "good code" connotatively, but instead we must define it enumeratively. For instance, D. J. Bernstein writes good code.

I dunno, maybe I'm just crazy.
Nick Mudge
7 June 2008

If code is unmanageable then it isn't simple and clear.
Mike
7 June 2008

I'm reminded of "The Elements of Programming Style", by Kernighan and Plauger. It's from the mid-70's, and examples are mostly Fortran and PL/1, but I think it worries about the same things you do: correctness, readability, etc.
Elvis Montero
www.elvismontero.com
7 June 2008

I, as many other folks out there, happen to think that "good code" is maintainable code. It's great if your code adheres to the specifications, delivers the functionality expected and does not consume lots of computing resources while maintaining decent execution speeds. However, all that is to little avail if the next folk (whoever that is) is unable to pick up your code and modify it easily.

In a world of changing business requirements, I think this is one of the most important metrics of good code (and thus, good programming) nowadays.
Dave
7 June 2008

I think simple is being under valued:
simple=maintainable
simple=less documentation required to modify, use
simple=manageable
simple=easier to test than a complex mass of dependencies
simple applies to UI's as well.

The original post is gold.
Name: (required)
Email: (required)
Website:
What has four legs, rhymes with bat and says, "Meow?" (One word answer.)
Spam Filter: