What I learned about code efficiency

simple

When I just started to code I discovered how beautifully logical and tidy you could build software. I grew convinced that good software should be like paintings, sculptures, digital haiku’s. I started to apply conventions in my code which I then deemed very important! Correctly indenting, coding in paragraphs, using curly brackets with all if and else‘s even if only one line would follow. I used to make a big issue about whether or not to use a semicolon after every line of code.

At a certain point I was even trying to keep the lines length within the width of my editor because I do not like the way line-wrapping looks. (although the Espresso editor does a really good job on that.)

I had the same stance on HTML. Which was easier in the beginning, not using any server side coding or writing it inline, right there in the markup. And when I started using server-side-inclusion I even indented the included markup so it would all look beautiful when you would View source in the browser. It got a lot harder when I learned to separate the code from the markup. Now I could use the same HTML snipets in completely different parts of the templates with completely different indentations. Around the same time I was looking into obfuscating the javascript I wrote. Back then I thought I made such fantastic, effictient code and I wanted nobody else to profit from it.

But my attitude towards code efficiency, correct indentation, short-circuiting and other coding tricks and conventions changed. It seemed trivial how others would perceive the code and it became more important how people would perceive the results of the code. So my focus shifted from peers to customers and end users. This mainly had to do with becoming an entrepreneur. When working for a boss I felt a great satisfaction in being able to show off my work to my co-developers. We used to review eachothers work and tried to come up with smart improvements. This was so important that I would actually feel threatened when a new developer would join the ranks. Worse so if she could code more efficient than me. I would feel completely miserable for a while.

As developers we didn’t have much interaction with the customers or the end users of the work we did. Of course we had meetings with the project manager and we complied to the project briefing but almost the only feedback we got was from the project manager, returning from client meetings with or without corrections. And so we compared our ability to code fast, correct and, most of all, efficient to measure our own coding net worth.

When I started to work as an entrpreneur that needed to change. Suddenly I had to deal with both the customer and the end user. The things I talked about with my peers, displaying my experience and expertise in coding, meant absolutely nothing to them. They did not care the least for indentation, semicolons or short-hand code. Actually, they weren’t even aware those things existed and if they were it was not very interesting to them. That’s pretty harsh to comprehend for someone who thinks that those are the trades he is selling. At least it was for me. It took me a long while and I had a hard time figuring out that my customers are almost solely interested in a good product that works as expected. Of course they want it to be built well and reliable but how that looks on the inside is unimportant. And ask them if they’d rather have a working product quickly or a beautifully built product later, my experience is that a lot will choose the former. After all, this is business and there are budgets involved.

Efficient code has a lot of advantages; it’s easier to debug, to maintain and to re-use. But in the real world that never beats getting a product out the door sooner.