good: doc_file_parser
bad: x
bad: dcprsr
good: getFlightString()
bad: flightstr()
bad: myfun()
Writing code is writing. Write things in a thoughtful order. Each line is like a sentence, containing a complete idea. Don't write run-on sentences, with too many ideas in one sentence. In other words, if a single line of code is doing too much, break it into multiple lines. String lines together into thoughtful "paragraphs" that are grouped together in a way that makes sense.
It's as much (if not more) about communicating with yourself and other humans as with the computer.
Find some recent blog posts on code readability, variable naming, organizing code, and breaking code into functions.
Next, for whichever language you're using, figure out how to use an automatic formatter and linter. These tools will standardize your code, making it easier to pattern match.
Finally, just write a lot of code and continuously learn and get better. Eventually you'll become great at using your chosen language(s) and understand programming in general, and you'll be able to read code just like you can read natural language.
Also if you get some code from Stack Overflow etc, then leave yourself a comment of the link you found the code/library too.
I'd recommend reading a few opinionated books on code.
Some you might want to look at.
Clean code Pragmatic programmer Domain Modeling Made Functional
Anything that gets you thinking about code structure. Explore the ways that work for you. Don't take them as gospel but explore the thinking.
- Be thoughtful in how you segment you code into functions/classes/modules. Designing well contained and intuitive interfaces is the foundation of computing.
- When something isn’t intuitive, consider adding a comment.
I constantly wish i wrote more documentation for my old code. Especially those that "i probably won't need to touch this anymore in the future"
Add comments explaining exactly what you needed to figure out this time around
Pretty soon you'll get the hang of what to put in the comments right away
Link:https://www.quora.com/It-takes-me-a-while-to-re-understand-t...