In the past, I have coded with some very bright and talented developers. Software development is like art, and I’ve worked along-side some true code artists. Their code is clean, readable, and expressive. Because of the care that they put into the design of their code, other developers can open the code base and, with a normal level of skill, modify or extend it with little or no prior knowledge. They are efficient and conscientious. I have a lot of respect for software developers like the guys with whom I’ve had the pleasure of working. I want to be just like them.
And then there’s the other type of developer. We’ll call him Einstein. Einstein is super smart. He thinks on a whole ‘nother level. In fact, he’s so smart that when he writes software, he writes it on a whole ‘nother level. On the UI level, the program runs and performs well. It does everything that it’s supposed to do. It might even do it REALLY well. Einstein has certainly outdone himself. He finished the project a few days early and the client is happy with the product.
Fast forward 6 months when the client needs to add a feature. Einstein is tied up with another project. The client has to hire another developer to modify the code base. We’ll call him Innocent Bystander. The client says to Innocent Bystander, “We’re really happy with Einstein’s work. You should have no trouble at all modifying this program.” So, Innocent Bystander cracks open the code and starts reading.
What he finds is a code base that only an author could love. It’s a tangled mess of spaghetti code and obscurely reused code blocks. Variables are named with acronyms that have long since been forgotten. There are no tests to show how code is expected to behave. Classes and methods cover pages and pages of scrolling. Nothing makes sense. It’s like trying to listen in on an encrypted conversation. The code base, for all intents and purposes, is encrypted.
So, Einstein was so “smart” that he wrote a code base that no one but he could understand. Innocent Bystander has accepted the task of adding a feature to that code base. Innocent Bystander has a couple choices… 1) Spend hours of the client’s time decrypting, modifying, and handling regression, or 2) Spend hours of the client’s time re-writing a section of the code, re-factoring the code that uses it, and handle regression. Either way, the client pays more than he should. Either way, there is regression. At least with the second option, the code base is left a little better than how Innocent Bystander found it.
Friends, countrymen, fellow developers. PLEASE please pLeAsE hear me out. If you are an Einstein and you’re still reading this… welcome to your first step to recovery. Admit you have a problem and start thinking about others while you code. Think about your client. Think about the next guy who has to come behind you. You don’t want either to hate you, right? Learn how to code in maintainable ways.
If you want to make sure your code is removed or re-written, just make it complicated and convoluted. No one will be able to follow your code and, boom… mission accomplished. You’ve effectively wasted the money of your client. The world would have been better off if you had applied your vast, immeasurable intelligence to something that lends itself to tangled webs of scattered thought process.. not software development.
If you want your code to stick around and make a difference, write it so that the next developer can read and understand it. Name your variables and methods to express their intent. Adhere to engineering principles like Single Responsibility, Open-Closed, and Dependency Inversion. Code in standard ways. Don’t try to be clever by stuffing loads of functionality into one reusable function. Spend time learning new ways to make your code expressive and readable.
No one cares how smart you are. It matters not that you’re on a whole ‘nother level. People only really care about your contribution over the long-haul. Clients may love you when you deliver the product early like a rock star, but the will cease to love you later when they have to pay again for the same code. No one will write blog articles about your awesome “swiss-army-knife-function-that-does-everything”. No, sir… in fact, they’ll write blog articles like this one.