by morbidhawk on 11/10/17, 5:27 PM with 1 comments
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!
by oblib on 11/10/17, 6:01 PM
I comment my own code very heavily so I don't have to spend as much time studying it at a later date.
And I don't try to get too tricky either. I don't fret over converting a block of code into an obfuscated one liner. I avoid that instead.