Reputation: 5403
Has somebody tried any tools for design patterns recognition in source code?
I'm looking for one that is more or less effective and expects some reasonable input (for example, an xmi file produced by a reverse engineering tool or another data that can be easily generated from the source code).
I've found some academic tools like CrocoPat, Columbus + Maisa, but haven't tried them yet.
Would appreciate if someone shares his/her experience in such experiments.
Upvotes: 3
Views: 1407
Reputation: 95392
Design patterns don't usually appear directly in code; usually the code contains an implementation of a design pattern.
To do such pattern recognition you need:
There aren't a lot of tools that can do this. While we have not explicitly hunted for general design patterns, we have built a tool that meets the criteria above: our DMS Software Reengineering Toolkit. DMS can parse C, Java and COBOL at the same level of precision as their compilers, can pattern match using explicit patterns, and computes control and data flow analysis for those languages.
One interesting application of DMS was to recognize the "design pattern" for producing interactive screens in a 35 million line C application. You know this design pattern: "use printf to produce fragments of the screen output". While it is easy to recognize fragments of the pattern (most printf calls are examples), the real problem is to recognize the screen image itself from a tangled pile of code that implements it. The task we accomplished was extracting an image of printed screen output (reported as an XML file containing screen literal text and XML tags representing variable-content output) by tying together the individual printf calls. The details for accomplishing this are pretty complicated; you have to find sequences of printfs that typically cross function calls and are controlled by lots of conditionals (the XML recorded the conditional part of the screens, too). The tool produced screen images for all screens printable by the code starting from main.
If you are hoping to find an easy solution for design pattern recognition, I think you will not have a lot of luck, but it is possible.
Upvotes: 1
Reputation: 30733
I don't know of anything that works. There is a lot of information that gets lost when you realize your patterns in code so reverse engineering them is bound to fail.
Upvotes: 1