More Code != Better Code

This is something I thought I should do a quick post about, I have encountered it multiple times with both software engineer managers and recruiters in general and I always cringe when it comes up. “How many lines of code have you written?” and “How many lines of code did you write today?”. These statements typically come from those in charge of engineers with no former technical background or from recruiters that are just out to fill a quota or maybe they are completely unware of what the underlying mechanics of software development are and this is just a left over question that works well for other professions.
For instance if you were hiring a salesman, you might ask them “how many units of X did you sell ?”, This is a perfectly valid question as you could figure out how effective the sales would be because there is a direct correlation with a performance metric, in this case the performance metric is selling units. This also works for positions like accountants where you could ask “how many transaction reports have you done?”, From this you could figure out if an accountant was familiar with a transaction report and how many they have done in the past.
Software development is traditionally employed as a future cost savings measure or to build a particular software product that accomplishes a certain task, its value is in whether or not it accomplishes the task and how much total man-hours it saves. So if we apply the question “How many lines of code have you written?” we are not questioning a final end product like a salesman to get a figure. This question starts to lose meaning as the main goal was to save man hours or produce a certain result, It would be better to ask “How many X man hours did this application save?”. So asking about the number of lines of code in a particular application is irrelevant.
What’s worse is that this question is completely worthless in determining technical ability as well. When asking how many lines of code someone has written, you are asking about strictly quantity, there is no way to know how many lines of code might be redundant or if maybe the code is completely inefficient in doing its intended task. Without a gauge on the quality of code then the number of lines should be irrelevant. Let’s say a snippet of code was copied and pasted throughout various parts of an application, congrats the total line count increased, this must be good right? WRONG, this also presents a problem as all this code might have been able to be condensed into a helper class, which would do the exact same functionality but result in far fewer lines of actual code and would be easier to maintain, code duplication could be a sign that a system was designed improperly. So far this has been a look at the big picture, Let’s break this down to a section of code

public String getTitleNavContainer(boolean isThisLandingPage) {
	if ( isThisLandingPage ){
  	return StringUtils.EMPTY;
	}
	else{
  	return "title-nav-container";
	}
}
public String getTitleNavContainer(boolean isThisLandingPage) {
return isThisLandingPage ? StringUtils.EMPTY : "title-nav-container";
}

With these two examples the first one would be the best right? It has more lines of code so it must be better. Well the problem is both of these snippets do the exact same functionality. The second one is logically equivalent and is condensed into a single line and is simple and concise. This is where using lines of code as a metric completely falls apart, in programming languages you can write logically equivalent code in a variety of ways it makes a tough case to use it as a metric as a person’s coding style would directly affect the number of lines.

So when I hear “How many lines of code have you written?” and “How many lines of code did you write today?”. Maybe its time to take a step back and ask what are they trying to evaluate. As just using line counts as a metric doesn’t give you any actual insight to an application or the person that wrote the application.