
As programmers, we've all seen source code that's so ugly and buggy it makes our brain ache. Over the past five years, authors Dustin Boswell and Trevor Foucher have analyzed hundreds of examples of "bad code" (much of it their own) to determine why they're bad and how they could be improved. Their conclusion? You need to write code that minimizes the time it would take someone else to understand it -- even if that someone else is you. This book focuses on basic principles and practical techniques you can apply every time you write code. Using easy-to-digest code examples from different languages, each chapter dives into a different aspect of coding, and demonstrates how you can make your code easy to understand. Simplify naming, commenting, and formatting with tips that apply to every line of code; Refine your program's loops, logic, and variables to reduce complexity and confusion; Attack problems at the function level, such as reorganizing blocks of code to do one task at a time; Write effective test code that is thorough and concise, as well as readable. - Publisher.
What these comments do is give the code structure, and giving an outsider a better/faster view into the code, when he has no internal model for the library/framework/API/language which helps him recognize the statements (this outsider might be the author himself, or "future me").
Not knowing what these lines do, I can at first glance (i.e. skimming through the code) understand the author's intentions, what each line is responsible for. This is simply reduction of mental load and I even do this just for myself when trying to wrap my head around a new library or language.
On the other hand, if you are writing for a (large) internal codebase, where you need to find a tradeoff between reduction of mental load and bloat, such comments can quickly become a nuisance...
Then again, the cost of useless comment is usually much smaller than the cost of mental load (everyone knows how to ignore comments, unless they fill pages...)
All this being said, I can only recommend "The Art of Readable Code" - Boswell [1].
[1] https://www.oreilly.com/library/view/the-art-of/978144931848...
Algorithms Unlocked, Thomas Cormen, 212 pages
The Art of Readable Code, Dustin Boswell & Trevor Foucher, 180 pages
How To Take Smart Notes, Sonke Ahrens, 151 pages
How to Write a Thesis, Umberto Eco, 223 pages
How Charts Lie, Alberto Cairo, 193 pages
Try The Art of Readable Code (a pair of google authors, IIRC), and Ousterhout's A Philosophy of Software Design.
Robert C. Martin, Clean code: https://www.amazon.com/Clean-Code-Handbook-Software-Craftsma...
Vaughn Vernon, various: https://vaughnvernon.co/?page_id=168
Steve McConnell, Code Complete: https://www.amazon.com/Code-Complete-Practical-Handbook-Cons... 2
Clean coder: https://cleancoders.com/ videos
Hunt and Thomas, The Pragmatic Programmer: https://www.amazon.com/Pragmatic-Programmer-Journeyman-Maste...
Hitchhiker's Guide to Python: https://docs.python-guide.org/
Dustin Boswell The Art of Readable Code: https://www.amazon.com/Art-Readable-Code-Practical-Technique...
John Ousterhout, A Philosophy of Software Design: https://www.amazon.com/Philosophy-Software-Design-John-Ouste... This one looks particularly interesting, thanks AlexCoventry!
Kent Beck, Test Driven Development: https://www.amazon.com/Test-Driven-Development-Kent-Beck/dp/...
Dan Bader, Python Tricks: The Book: https://dbader.org/
Ian Sommerville, Software Engineering: https://www.amazon.com/Software-Engineering-10th-Ian-Sommerv...
Svilen Dobrev, various: http://www.svilendobrev.com/rabota/
The code I find most readable is imperative code that can be read line-by-line. I find abstractions hide away important knowledge of understanding completely how things work. Additionally I prefer reading algorithmic code than reading a bunch of helper functions that are at a level of indirection away from understanding the code at hand. For this reason I try to write in more imperative style instead of OOP or functional. But I find that programs I write that can be followed line by line end up having a lot of variables that make it hard to keep track of everything.
I've tried to look for other projects that can be read line by line easily but I haven't found one yet. I'll end up spending way to much time trying to figure out what helper objects, functions, or structs are doing and they require jumping to a bunch of other files while trying to keep in my head what I read previously.
It seems these 2 things are at odds with each other: readable code vs code that can be read and understood completely. I don't want algorithms hidden away but when they are right there in place with the other code it becomes too much.
Is completely readable code even possible? I've heard "abstract just barely as much as you need" or "just use right level of abstraction" but that doesn't give me anything concrete I can do. Is there a project that you know about that was large but very easy for a new person to read and understand completely? Do you know how to write code like that?
Any ideas are appreciated. Thanks!