TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: How do I quickly re-understand the code I wrote? I am a beginner btw

10 pointsby anon115about 3 years ago

10 comments

bckrabout 3 years ago
Name things properly. Don&#x27;t use the old-fashioned naming conventions that try to minimize the length of names.<p>good: doc_file_parser<p>bad: x<p>bad: dcprsr<p>good: getFlightString()<p>bad: flightstr()<p>bad: myfun()<p>Writing code is <i>writing</i>. Write things in a thoughtful order. Each line is like a sentence, containing a complete idea. Don&#x27;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 &quot;paragraphs&quot; that are grouped together in a way that makes sense.<p>It&#x27;s as much (if not more) about communicating with yourself and other humans as with the computer.<p>Find some recent blog posts on code readability, variable naming, organizing code, and breaking code into functions.<p>Next, for whichever language you&#x27;re using, figure out how to use an automatic formatter and linter. These tools will standardize your code, making it easier to pattern match.<p>Finally, just write a lot of code and continuously learn and get better. Eventually you&#x27;ll become great at using your chosen language(s) and understand programming in general, and you&#x27;ll be able to read code just like you can read natural language.
groffeeabout 3 years ago
Comment your code. Not just the what it does, but the why as well. Basically document everything in your comments, approaches you tried, what worked, what didn&#x27;t etc.<p>Also if you get some code from Stack Overflow etc, then leave yourself a comment of the link you found the code&#x2F;library too.
评论 #31381967 未加载
xupybdabout 3 years ago
This is the trick to writing good code. It reads like a novel. I&#x27;ve never written code that well but the closer it gets to that the better I&#x27;m doing. I&#x27;m also assuming performance and correct code as goals.<p>I&#x27;d recommend reading a few opinionated books on code.<p>Some you might want to look at.<p>Clean code Pragmatic programmer Domain Modeling Made Functional<p>Anything that gets you thinking about code structure. Explore the ways that work for you. Don&#x27;t take them as gospel but explore the thinking.
wbsss4412about 3 years ago
- Be thoughtful with the names you use, variables should have names that represent what they hold, functions&#x2F;classes should have names that represent their behavior.<p>- Be thoughtful in how you segment you code into functions&#x2F;classes&#x2F;modules. Designing well contained and intuitive interfaces is the foundation of computing.<p>- When something isn’t intuitive, consider adding a comment.
michaelsalimabout 3 years ago
In addition to comments and descriptive descriptive variable names, document everything!<p>I constantly wish i wrote more documentation for my old code. Especially those that &quot;i probably won&#x27;t need to touch this anymore in the future&quot;
forgotmypw17about 3 years ago
Good variable names<p>Add comments explaining exactly what you needed to figure out this time around<p>Pretty soon you&#x27;ll get the hang of what to put in the comments right away
t-3about 3 years ago
If you don&#x27;t quickly understand the code, reread it and look at appropriate documentation until you do. With practice the patterns and idioms will become second nature, but you must practice. It takes years of reading to get to a high level in natural language, and programming languages are no different.
pizzaabout 3 years ago
to understand a new codebase, unit tests are the first thing i read. hopefully things are tested in isolation to a sufficient degree that you don&#x27;t have to spend a lot of effort keeping track in your head very much to follow the flow of code.
anon115about 3 years ago
posted question on Qoura too.<p>Link:<a href="https:&#x2F;&#x2F;www.quora.com&#x2F;It-takes-me-a-while-to-re-understand-the-code-I-wrote-How-do-I-get-quicker-at-reunderstanding-it" rel="nofollow">https:&#x2F;&#x2F;www.quora.com&#x2F;It-takes-me-a-while-to-re-understand-t...</a>
rufus_foremanabout 3 years ago
You can&#x27;t. You&#x27;ll have to rewrite it.