Like most of us I like pretty things. And when I see a thing of beauty it makes my heart sing. However this is not why I struggle to write beautiful code. Now I’m not talking about style, although that helps. And I’m not talking about coding standards, although that is also a significant factor.
A friend of mine, Charlotte, makes beautiful keepsake boxes. She gets plain boxes and turns them into beautiful keepsakes using her skills as a craftsperson.
Beautiful code is crafted. Like these beautiful boxes.
But why bother? I’m not trying to make a work of art, I’m trying to fulfil someone’s need.
As my friend Tay said, often when you have beautiful code an amazing thing happens. You find that it has less bugs. You find that when the code is called by another module or system, then everything just works. It does what it says on the tin. More beautiful code simply seems to follow.
So do you try and write beautiful code? I would love to know how you achieve it in your world, so feel free to leave a comment.