TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: Reading another developers code

3 点作者 bjw181超过 8 年前
How do you go about becoming intimately familiar with someone else's previously written code in order to work with it or build upon it?

3 条评论

zouhir37超过 8 年前
Here&#x27;s how I tackle it:<p>- if there&#x27;s good unit tests, I immediately feel more comfortable and confident as nothing can explain the code and behaviour more than the test suit.<p>- if there&#x27;s no Tests, but can allocate sometime to think and write tests. that&#x27;s the best documentation you&#x27;ll ever provide and benefit from.<p>- With better languages debuggers things are easier, logging to the console keeps to make me win quicker in some cases!<p>- Really long comments are confusing sometimes. and might make things more complicated than simple.<p>- Time will help you get everything. The more time you allocate to focus on the codebase you&#x27;ll find yourself more familiar. If you have time, make sure you don&#x27;t stress yourself and stare at it too long. take breaks do other things and come back to it once you brain is cleared.<p>- before you build on top: Once you understand most the ins and outs, try to burn down bugs before building on top.<p>finally - it is OK if you don&#x27;t know 100% of the code. no one can easily know a whole code base they didn&#x27;t write!
xja超过 8 年前
I guess it really depends.<p>On projects where the level of commenting is low and theirs little to no documentation it can be tough.<p>For C projects as there&#x27;s usually a single point of entry I just start with main() and read through the code to get a conceptual overview of what&#x27;s happening. Often I find it useful to comment the code&#x2F;write basic documentation as I go.<p>Then I often attempt small changes&#x2F;refactoring to attempt to validate my understanding. Often I&#x27;ll add code to dump intermediate data to better understand what&#x27;s happening.<p>It can be quite a slow process in a large project to be honest, and it&#x27;s a lot easier if you have the original developer available to ask questions.
greenyoda超过 8 年前
You might be interested in this discussion from a few days ago: <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13282756" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=13282756</a>
评论 #13371700 未加载