c# 代码流映射/可视化实用程序?
我被要求重写(从头开始)现有的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从头开始重写代码可能是一场灾难:请参阅: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
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:
When to rewrite a code base from scratch
Is this the "one in ten" time to rewrite?
Rewrite of legacy code
看看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.
我非常确定,虽然整体无效,但现有代码的某些部分非常好。我建议您采取这些部分,在它们周围进行单元测试,然后喘口气,将它们复制粘贴到您的新项目中。这样,你就会一点一点地把你的混乱过滤成重新塑造和测试的东西。
另外,我一直想做的就是打印大量代码并通过切割(使用真正的金属剪刀)并将它们重新粘贴在一起来可视化工作流程。
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.