c# code flow mapping/visualization utility?
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.
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:
When to rewrite a code base from scratch
Is this the "one in ten" time to rewrite?
Rewrite of legacy code
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.
精彩评论