简体   繁体   English

适用于C ++的优秀代码可视化/重构工具?

[英]Good code visualization / refactoring tools for C++?

I've found myself coming across a lot of reasonably large, complicated codebases at work recently which I've been asked to either review or refactor or both. 我发现自己最近在工作中遇到了很多相当大而复杂的代码库,我被要求进行复审或重构或两者兼而有之。 This can be extremely time consuming when the code is highly concurrent, makes heavy use of templates (particularly static polymorphism) and has logic that depends on callbacks/signals/condition variables/etc. 当代码高度并发,大量使用模板(特别是静态多态)并且具有依赖于回调/信号/条件变量/等的逻辑时,这可能非常耗时。

Are there any good visualization tools for C++ period, and of those are there any that actually play well with "advanced" C++ features? C ++期间是否有任何良好的可视化工具,其中有哪些实际上与“高级”C ++功能相配合? Anything would probably be better than my approach now, which is basically pen+paper or stepping through the debugger. 任何事情都可能比我现在的方法更好,这基本上是笔+纸或踩过调试器。 The debugger method can be good for following a particular code path, but isn't great for seeing the big picture you really need when doing serious refactoring. 调试器方法可以很好地跟踪特定的代码路径,但是对于在进行严格的重构时看到真正需要的大图片并不是很好。

EDIT: I should mention that Visual Studio plugins aren't going to be a lot of help to me, since our stuff is mostly Linux-only. 编辑:我应该提一下,Visual Studio插件对我来说不会有很多帮助,因为我们的东西主要是Linux。

You could use Doxygen to get you started; 你可以使用Doxygen来帮助你入门; once the easy part is done (class layout, hierarchies, ...) you need to write about the rest of the software that cannot be easily be process by tools like doxygen. 一旦完成了简单的部分(类布局,层次结构......),您需要编写其他软件,这些软件不能像doxygen这样的工具轻松处理。

good luck. 祝好运。

M. M.

Visualising: 可视化:

I'm not aware of what's going on outside of the UML world, but what is available within it does not reverse engineer modern, template based C++ at all well. 我不知道UML世界之外发生了什么,但是它内部可用的东西并不能完全逆向设计基于模板的现代C ++。 At best, you will get simple class diagrams. 充其量,您将获得简单的类图。

Refactoring: 重构:

Mozilla created the dehydra / Pork tools to analyse and refactor their C++ source to change their old-style XPCOM and memory management with better idioms. Mozilla创建了dehydra / Pork工具来分析和重构他们的C ++源代码,用更好的习语改变他们的旧式XPCOM和内存管理。 It's not tied to a visualisation tool, instead uses pattern matching and JavaScript. 它不依赖于可视化工具,而是使用模式匹配和JavaScript。 I haven't tried it myself, being fortunate to not having been in a position where it's required. 我自己没有尝试过,幸运的是没有处于需要的位置。

No. No. and No. You'll need to document and diagram the codebase by hand; 编号和编号您需要手动记录和绘制代码库; something that should already have at least been partially done. 应该已经至少部分完成的事情。

There's a refactoring tool, or at least claims to be, for xemacs. 对于xemacs,有一个重构工具,或者至少声称是。 There's one for VS but it doesn't work to great and only knew like 5-10 refactors. 有一个用于VS,但它不起作用,只知道像5-10个重构。 The xemacs one is like $250 or something. xemacs的价格是250美元或者其他东西。 Don't know of one for Eclipse. 不知道Eclipse的一个。 You'll most likely need to do your refactors by hand. 你很可能需要手工完成你的重构。

I am not aware of a refactoring tool for C++ that is even in the same league as for example the refactoring tools you can find for Java. 我不知道C ++的重构工具甚至在同一个联盟中,例如你可以为Java找到的重构工具。 Eclipse/CTD has some small refactorings (extract methods, make public/private/getter+setter) but thats about it. Eclipse / CTD有一些小的重构(提取方法,make public / private / getter + setter),但就此而言。

Still Eclipse/CDT is a good tool to get an overview of a huge code base. Eclipse / CDT仍然是一个很好的工具,可以概述庞大的代码库。 The code navigation features (show references, show definition, show declaration, class hierarchy, etc...) are the best i have seen in a C/C++ editor. 代码导航功能(显示引用,显示定义,显示声明,类层次结构等等)是我在C / C ++编辑器中看到的最好的。

I can't vouch for it but there is the CDT Refactoring Project . 我无法保证,但有CDT重构项目
edit: that page looks out of date. 编辑:该页面看起来过时了。 Maybe someone else can attest to the status of CDT refactoring? 也许其他人可以证明CDT重构的地位?

The DMS Software Reengineering Toolkit is a program transformation engine parameterized by language definitions. DMS Software Reengineering Toolkit是一个由语言定义参数化的程序转换引擎。 It has a full C++ front end, and has been used to carry mass refactorings of software systems coded in C++. 它有一个完整的C ++前端,并且已被用于进行用C ++编码的软件系统的大规模重构。

See Akers, R, Baxter, I., Mehlich, M. , Ellis, B. , Luecke, K., Case Study: Re-engineering C++ Component Models Via Automatic Program Transformation, Information & Software Technology 49(3):275-291 2007 for discussion about DMS and how it was applied to C++ modules to support avionics software. 参见Akers,R,Baxter,I.,Mehlich,M.,Ellis,B.,Luecke,K.,案例研究:通过自动程序转换重新设计C ++组件模型,信息和软件技术49(3):275- 291 2007年关于DMS及其如何应用于C ++模块以支持航空电子软件的讨论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM