So I’ve been around in the web industry as a professional for some time now, woo hoo! Now when anyone does something professionally for long enough time its only natural to hit a point where simply being able to do something isn’t enough. Anyone in the development field in any form will tell you that this point is what separates the good from the great. **Pats self on back**
Despite this need being vital to have a lasting career as a developer, it’s like a double edged sword. I’m saying this because there is a line that is often crossed in the development world between efficiency and readability. Let’s dig into this further.
Efficiency, In Code?
Defining what is efficient as far as the code someone wrights is a completely relative judgement scale based on the project. It would be a foolish effort to judge efficiency for a 5 year old legacy app on the same scale as you would for a brand new B2B site, too many variables.
In judging efficiency, what is common to do is to see if working code in place is done in without too much bloat and wasted function calls in the process. That may be hard to take in at first, probably because I’ve had a little too much tea right now, but we’ll clear that up quick!
So if you have two phones, one was thought of in detail at every step of the creation process and the other was thrown together quick to beat the Christmas rush. Which would you want? The well planned and thought out phone of course!
The same process is what any developer worth their paycheck does. A part of this of course goes to bragging rights, but the majority of it is attributed to not wanting to have to deal with a big mess a little later down the line. In addition, in that causing desire for efficient code lies why readability is so important.
What Exactly Makes Code Readable?
Writing efficient code is a dedicated task that while challenging, can be achieved at different time intervals based on experience. However, not all efficient code is good code.
The issue that has many, including myself for a minute, amiss with code efficiency is when its taken to the point where readability is sacrificed. Being able to transform a 15 to 20 line code block into three or four is great, but only if its done effectively. For example imagine a multi line if statement, and you simply turned it into a one line statement.
In this instance perceived looks were valued more than code improvement. That’s not good!
When writing code, the main issue that plagues all developers is coming back to code later. The fast pace of the industry calls for us to write a lot of code at a pace that when its done its impossible to remember what it actually does.
Thats why its important to write code in a way that let’s you go away for months in a time, or allow for a new developer to the code, to pick up the flow as quick as possible.
How To Find The Balance
In my internal struggle to find the center point between efficiency and readability, I found myself and a mental stopping point. Here I took some time to think about what I found to be the only solution for these issues in my 20 years of life, break it down and out!
Most of the complicated issues and problems we experience in life are because everyone wants to micromanage and worry themselves to death about some bigger meaning to something. That’s considerable close to career suicide for a developer. So let’s break things down as so with these few questions…
- Is the code written in the most efficient way?
- In this efficiency, is there any area that looks confusing?
- Is this efficiency accomplished with multiple if break outs?
- Did you only write it that way because of being aggressively rode about a tight deadline?
- Would you be able to come back to it 2 years later and get it?