5 things I wish I knew before writing 1 Million lines of code
Take it from somebody having spent a decade writing code and teaching others

Manager — SDE
Search for a command to run...
Take it from somebody having spent a decade writing code and teaching others

Manager — SDE
No comments yet. Be the first to comment.
← Previous: What’s New in the SDK and Tooling for .NET 9 .NET Aspire is a set of tools, templates, and packages designed to help developers build observable, production-ready apps that embrace cloud-native and distributed computing best practices. .N...

← Previous: What’s New in .NET Libraries for .NET 9 The .NET 9 SDK introduces several new capabilities and improvements to streamline development workflows, enhance build and test experiences, improve NuGet security and performance, and provide great...

← Previous: What’s New in .NET MAUI for .NET 9 .NET 9 adds a wide range of enhancements and new APIs across the base class libraries. These improvements touch everything from low-level data structures and cryptography to JSON serialization, text pr...

← Previous: What’s New in ML.NET .NET Multi-platform App UI (.NET MAUI) in .NET 9 focuses on improving overall product quality, test coverage, performance, and stability. While previous releases introduced major new capabilities and controls, the emp...

← Previous: What’s new in ASP.NET Core 9.0 ML.NET continues to evolve as a full-featured, open-source machine learning framework for .NET developers, enabling you to create, train, and deploy custom ML models directly in your .NET applications. ML....

Developers spend much more time reading the code than writing it. So, after optimizing code for time and space complexity — optimize it for reading complexity. There’s even a term for that — Cyclomatic Complexity.
After having written more than 1 million lines of code and having read much more awful lot, here are the top 5 things I wish I knew sooner to write more readable code.
A common misconception among upcoming and new developers is — Software Development is about writing the O(n) complexity code of binary tree inversion. And I hate to break it to you — it’s not.
A lot of time it’s about, adding a new feature or fixing a bug in an existing code base with its own coding conventions, naming conventions, design, and architecture. So reading and understanding the existing code becomes one of the most important parts of the job.
Great developers spend a lot of time reading other people’s code.
In almost all programming languages and frameworks, there are numerous ways of doing the same thing. The smarter and one-liner way may feel good to write at the moment, but often it’s not good for the next reader — which can be YOU six months down the line.
So,
If there is a little more verbose but more readable way to do it — do it and your future self will thank you later.
Usually, I’m against documentation. Because
The code is literally the instructions written to build something.
The only parts that need documentation are the “why”. Why we’ve written this piece of code this way?
If you don't understand the "what"? Maybe you shouldn't be the one changing it.
function/method does in the name.There are only 2 difficult things in Computer Science — Cache Invalidation and Naming
Just by reading the name of the function, its intent should be clear.
“But then large functions would have way big names” — that’s the point. Your function should do only 1 or a few things and do it properly.
Refactor the
function/methodif it’s job can’t be described in the name.
“There’s no time to write good code” is not a good enough excuse for writing bad code.
Checking for the readability of your code is like flushing the toilet — it’s part of the ceremony. You do it no matter how late you are for anything else.
So next time you write code, think about your future self, what would you answer to that person? Don’t bring shame to yourself. Write readable code.
Happy Coding!