如何在不了解架构的情况下阅读代码 [英] How to read code without knowing archicture

查看:66
本文介绍了如何在不了解架构的情况下阅读代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我是有两年经验的程序员.我可以编码.我知道VC ++/C#/WPF.我很少会遇到编写新代码的麻烦,但是当要阅读别人编写的代码时,事情就开始出错了.我在阅读代码时遇到了麻烦.

有人可以建议我应该如何开始阅读代码并了解已经编写的代码的体系结构.有时候,我只是想了解代码,只是因为我其他时候刚加入团队时,我需要修复错误.您能建议任何博客或任何可以帮助我高效阅读代码的建议吗?

预先感谢.

Hi All,

I am programmer having two years of experience. I am OK with coding. I know VC++/C#/WPF. I rarely have trouble writing new code, but when it comes to read code written by someone else, things start going wrong. I have real trouble with reading code.

Can anybody please suggest how should I start reading code and understand architecture of already written code. Sometimes I just wanted to understand code just because I newly join the team other times I need to fix a bug. Can you please suggest any blog or any suggestion which will help me in efficient code reading.

Thanks in advance.

推荐答案

这不是我们可以真正回答的问题.

您还需要问自己一个问题:

为什么我在阅读别人的代码时遇到问题?"

是因为它们使用了您不知道的.NET或C#的一部分?
是他们使用了您不理解的模式吗?
还是因为他们的编码风格与您完全不同?
还是因为他们是一群无才的白痴?

如果您对前三个条件中的一个或多个回答是",那么您应该已经知道需要做什么.
如果对最后一个回答是",那么您很可能需要重新考虑自己的态度.可能不是,但他们对您的想法也一样...


这不是一件容易的事,但是随着经验的积累,它会变得更加容易.项目越大,难度就越大.有一些事情可以帮助您:公司范围内的代码,注释和文档标准.例如
但是恐怕没有一个单一的执行此操作"答案.
It''s not a question that can be really answered by us.

It''s more a question you need to ask yourself:

"Why do I have a problem reading other peoples code?"

Is it because they use parts of .NET or C# you don''t know?
Is it that they use patterns you don''t understand?
Or because their coding style is totally different from yours?
Or perhaps, because they are a bunch of talentless idiots?

If you answered "yes" to one or more of the first three, then you should already see what you need to do.
If you answer "yes" to the last one, then you may well need to rethink your own attitude. The chances are they aren''t, but that they think the same about you...


It''s not a simple thing to do, but it gets easier with experience. The bigger the project, the harder it is. There are things that can help: company wide standards for code, commenting and documentation for example.
But there isn''t a single "do this" answer you can be given, I''m afraid.


如果已经有一些文档,我建议您阅读首先,您应该从业务/用户角度熟悉每个模块的功能.如果没有,那么您可能需要花费一些时间来熟悉一下,因为您需要阅读大部分(如果不是全部)代码.就个人而言,我通过在调试模式下运行应用程序来熟悉它,并在一些我不熟悉的部分上使用断点.我使用不同的输入,看看会发生什么.另外,与其他团队成员一起提问可以帮助您更快地熟悉系统.
If there''s some documents that are already written, I suggest you read them first for you to be familiar on the function of each module on a business/user perspective. If there''s none, then it might take time for you to be familiar since you will need to read most of the code, if not all. Personally, I become familiar with it by running the application in debug mode and use break points on some parts that I''m not that familiar. I use different inputs and see what happens. Also, asking questions with other team members can help you become familiar with the system faster.


经验,亲爱的,经验和耐心.
您处理的大多数代码可能根本没有体系结构,只是疯狂的想法的临时产物(就像您或我的一样).
Experience, my dear, experience and patience.
Most of the code you deal with probably has no architecture at all, it is just the extemporary product of a crazy mind (just like yours or mine).


这篇关于如何在不了解架构的情况下阅读代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆