4 ms·
Name things properly. Don't use the old-fashioned naming conventions that try to minimize the length of names. good: doc_file_parser bad: x bad: dcprsr good
by bckr 4y ago
Name things properly. Don't use the old-fashioned naming conventions that try to minimize the length of names.
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.