c# 代码流映射/可视化实用程序?

发布于 2024-10-31 17:39:13 字数 354 浏览 5 评论 0原文

我被要求重写(从头开始)现有的 C# winforms 应用程序。不幸的是,在过去的三四年里,这段代码已经被至少十几个不同的开发人员修改过,他们似乎都没有遵守任何类型的编码标准。客气地说,这个代码库一团糟。考虑到代码的量级(约 24k 行)以及代码对我来说是全新的,我希望找到某种实用程序来帮助我更快地理解该应用程序在高级别上的工作方式。请记住,此代码中似乎没有大量良好的 OOP 实践,因此我需要比类图更详细的内容。我看过有关生成序列图的参考资料,这可能更像我正在寻找的内容,但我只有 VS2010 Premium,而且我的印象是此功能仅由 VS Ultimate SKU 提供。我可以访问当前版本的 .NET Reflector,并且看到一些人提到有一些插件可能有用,但我没有任何具体名称。

I've been asked to re-write (from the ground up) an existing C# winforms application. Unfortunately, this code has been modified by at least a dozen different developers over the past three or four years none of whom seemingly adhered to any kind of coding standard. To say that this code base is a mess would be putting it politely. Given the magnitude of the code (~24k lines) and the fact that the code is completely new to me, I'd like to find some kind of utility that will help me to more quickly understand how this application works at a high level. Bear in mind that there don't seem to be an abundance of good OOP practices in this code so I need something a little more detailed than class diagrams. I've seen references to generating sequence diagrams which might be more like what I'm looking for but I only have VS2010 Premium and I'm under the impression that this functionality is only provided with the VS Ultimate SKU. I have access to the current version of .NET Reflector and I've seen a couple of people mention that there are plug-ins for that which might be useful but I don't have any specific names.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

爱已欠费 2024-11-07 17:39:13

从头开始重写代码可能是一场灾难:请参阅:http://www.joelonsoftware.com /articles/fog0000000069.html

这不是一项容易的任务,因为您提到在您之前有十几位开发人员。
每个开发者的背后都有他自己的方法论和他自己的系统逻辑。每个人
他们以自己的方式行事。

以下是您可能会遇到的一些问题

  • 遵循其他开发人员的逻辑
  • 该开发人员是否仍然存在,或者是否已更换职位或更糟糕的更换工作
  • 查找或即使存在技术规范(这是最重要的)
  • 最初的遗留代码编写,然后修补,然后一次又一次地修补...
  • 可能已在应用程序中集成或编写的自定义代码
  • 安全性(如果有)

除了拥有一堆应用程序的流程图/图表之外,最好要求或获取的是技术规格。该计划的目的是什么?考虑到还有其他 12 个人参与了该计划,您可以自己承担吗?

您提到了 OOP,您是否计划采用意大利面条式代码并进行整个重写以适应面向对象模型?如果是这样的话,那就需要做大量的工作了……而且有 12 个先前的大脑在处理这个问题,某人的逻辑肯定会让你犯错。

抱歉,我没有最好的建议,但这可能是一项艰巨的任务......尤其是如果您之前的那些开发人员不再在那里的话。

有关详细信息,请参阅这些 SO 线程:

Rewriting the code from scratch can be a disaster: See this: http://www.joelonsoftware.com/articles/fog0000000069.html

This is not an easy task as you mentioned there were a dozen developers before you.
Behind each developer is his own methodology and his own logic of the system. Everyone
does it their own way.

Here are some of the problems you could encounter

  • Following another developers logic
  • Whether or not the developer is still around or has changed positions or worse changed jobs
  • Finding the or even if a technical specification exists (this is the most important)
  • Legacy code that was originally written, then patched, then patched again and again...
  • Custom code that might have been integrated or written within the application
  • Security if there is any

Besides having a bunch of flowcharts / diagrams of the application the best thing to ask for or obtain is the technical spec. What is the purpose of the program and given that 12 other people worked on it is it something you can take on yourself?

You mentioned OOP, do you plan to take spaghetti code and do an entire rewrite to fit the object oriented model? If so that is a lot of work...and with 12 prior brains working on it someone's logic is bound to trip you up.

Sorry I don't have the best advice, but this could be a daunting task...especially if those developers before you are no longer there.

See these SO threads for more info:

虚拟世界 2024-11-07 17:39:13

看看NDepend,它是一个代码管理工具,可以帮助你很多,感谢代码查询, 代码规则智能技术债务估计,依赖图表和矩阵,自基线以来的代码差异...

哦,还有 这个相关问题也

Have a look at NDepend, it is a code management tool that could help you a lot thanks to code querying, code rules, smart technical debt estimation, dependency graph and matrix, code diff since a baseline...

Oh, and this related question too.

败给现实 2024-11-07 17:39:13

我非常确定,虽然整体无效,但现有代码的某些部分非常好。我建议您采取这些部分,在它们周围进行单元测试,然后喘口气,将它们复制粘贴到您的新项目中。这样,你就会一点一点地把你的混乱过滤成重新塑造和测试的东西。

另外,我一直想做的就是打印大量代码并通过切割(使用真正的金属剪刀)并将它们重新粘贴在一起来可视化工作流程。

I'm pretty sure that, while the whole is invalid, some part of the existing code are perfectly good. I'd suggest that you take those part, put unit tests around them and gasp, copy paste them into your new project. That way, you will filter little by little your mess into something reshaped and tested.

Also, something I've always wanted to do is to print a lot of code and visualize the workflow by cutting (with real metal scisors) and taping them back together how they are used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文