Writing Code for Other People
Write code that you would enjoy reading.
A lot of developers, myself included, get caught up in being clever instead of being obvious. In my opinion this is a bad thing. Don't get me wrong, clever abstraction and new ways of doing things have their place in coding but I don't think it should be the "bread and butter" of what we do. We need to keep in mind that someone else will be reading this code in most cases or worse, they'll be updating and using this code in the future. That means that every coding decision you make should start with this in mind.
If you walked into a grocery store and all the food was hidden behind a series of Zelda-like puzzles a few things would happen. You would be confused, frustrated, and it would really slow you down. It's now what you expect to see when you go into a grocery store. You expect to see all the food nicely organized on shelves and even kept in aisles that group them together in common sense ways. Your code should be the same way.
When someone walks into your code they should mostly see what they would expect to see. The way that variables are declared, functions are called, and objects are created should all be very familiar to them if you want them to enjoy reading your code. No one wants to spend hours digging through line after line of your 'clever' code that only makes sense to you, when a more conventional way of doing the same thing is available. I'm not saying you shouldn't push the boundaries and try new things. I'm saying most of your code should be predictable, or even boring. If you want to save the reader, or your future self, some time then you had better stop being clever and start being predictable.Back to archives