Less Code, More Problems

Boss Programmer
2 min readJan 28, 2021

--

Why are so many developers obsessed with trying to write as little code as possible?

They act like human minifiers; selecting the shortest variable names possible, and writing functions in the fewest number of lines possible.

I’m not talking about elegant solutions here. Code can be bloated.

I’m talking about a fixation with fewer lines of code at the expense of readability and maintainability.

1. Readability

Self. Documenting. Code.

This should be a no-brainer for all devs. Unfortunately it isn’t.

I’d rather read a long variable name whose purpose I understand immediately, rather than a shorter one that needs to be cracked before it can be understood.

I’ve no qualms in stating that programmers that don’t conscientiously code for others to understand are bad team members.

❌ Wrong

var srsbn = someClass.someMethod();

✅ Right

var searchResultsSortedByName = someClass.someMethod();

2. Maintainability

Similarly, I’d rather read a longer function that’s easier to debug, rather than a shorter one that makes me curse the person that wrote it.

❌ Wrong

function someFunction(): someType {

return someClass.someMethod();
}

✅ Right

function someFunction(): someType {

var someValue = someClass.someMethod();
return someValue;
}

If I’m debugging the first function, how do I quickly see the return value if every function has a similar return statement?

Don’t write code thinking only of yourself. Write code thinking about others. Will they be able to easily understand and debug the code after you’re long gone?

--

--

Boss Programmer
Boss Programmer

Written by Boss Programmer

🚀 Helping aspiring developers land their first job and move up fast. ⏱ 15+ years industry experience. 👉 Visit bossprogrammer.com.

No responses yet