3

Our team is doing reverse-engineering on a application with virtually non-existant documentation. We want to detect if there's a use of architectural or design patterns. You may understand that this application is large, so looking manually is no sense for us.

This application is written in Java and we use Eclipse for IDE, so it may be a plugin for Eclipse.

We have found some tools, like "Design Patterns detections Similarity Scoring", but it's not working very well.

So, such tools do exists?

sgy
  • 2,922
  • 2
  • 35
  • 42
  • what exactly do you want to do ? – this. __curious_geek May 24 '11 at 15:16
  • I would look for the amount of dependencies, having a lot of hard dependencies could be a an indicator that your application is not loosly coupled and thus not making use of patterns very much (though loose coupling could probably achieved without design patterns :-)). – helpermethod May 24 '11 at 15:23

4 Answers4

3

If you have the source code of the app, you are most probably reengineering it, rather than reverse engineering. (The latter means recovering some sort of higher level code from machine- or bytecode).

At any rate, you want to understand the application, i.e. build a mental model of it in your mind. I am afraid automatic tools aren't of much help in this. What use would it be for you to get a list of supposed patterns in the code? Would it help you understand better what the code actually does and why? Especially taking into account the high chances of patterns being misused in legacy code :-(

In the end, you need to get down to reading the code anyway. But here is another similar thread which hopefully helps in the daunting task of taking over a legacy app.

Community
  • 1
  • 1
Péter Török
  • 114,404
  • 31
  • 268
  • 329
  • I'm not talking reverse engineering the "hacker" way, I'm talking reverse engineering the "software engineering" way. Reverse engineering, where you extract knowledge from code, is the step before the reengineeing. Please refer to the textbook "Object-Oriented Reengineering Patterns", figure 1.1 p.9. (http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.144.8636&rep=rep1&type=pdf) (I don't know why you had many votes. You don't answer the question.) – sgy May 24 '11 at 23:22
  • Reverse engineering is what Péter says. Ask any developer that got several years of experience from programming. Or refer to this wikipedia article: http://en.wikipedia.org/wiki/Reverse_engineering#Binary_software. Other than that, the answer that was linked is great. Read it. – jgauffin May 25 '11 at 06:10
  • @elbaid, I tried to help you solve your real problem (that is, reengineering a legacy app) instead of directly answering your concrete question. And I also attempted to explain why. But if you really want a direct answer, mine is "Probably not." ;-) – Péter Török May 25 '11 at 07:32
  • @elbaid, regarding reverse engineering, there are stricter and broader interpretations. You are right that in the broader sense, "Reverse engineering is the process of analyzing a subject system to create representations of the system at a higher level of abstraction". Note however, that this is a more academic definition, not very widely known in developer circles. – Péter Török May 25 '11 at 07:50
  • @jgauffin : In Wikipedia, it says : "The term reverse engineering as applied to software means different things to different people [...]", so maybe next time I should give my definition of an ambiguous word :) – sgy May 25 '11 at 20:04
  • @Péter Török : Thanks for your answer, in a second thought, I appreciate your explanation. Should I let the question open for now? Or you definitely think it's a final answer? – sgy May 25 '11 at 20:11
  • @elbaid, it's up to you to decide :-) As things are now, I don't see a high chance of getting a new answer very different from the existing ones. Unless, maybe, if you put a bounty on the question... – Péter Török May 25 '11 at 20:17
1

I do not believe these kind of tools exist, because that would be pretty complex. Another approach could be to generate something like an UML diagram. This should give an abstraction of the code which could help you identify the design pattern.

  • I don't think UML is very useful for this. The problem is, a UML reverse engineering tool will show you *all* details on the diagram, obscuring the really important ones. – Péter Török May 24 '11 at 20:10
  • For the first sentence ("I do not believe these kind of tools exist, because that would be pretty complex."), I think it's true. – sgy May 24 '11 at 23:24
0

I doubt there are tools out there for detecting patterns or designs in code

Code Bubbles could drastically help the reverse engineering effort, when it eventually comes out !

Lately, am finding it extremely useful to use code coverage tools to identify which parts of the code are called when a particular user/system action is initiated. It's not what the tools were designed for but am increasingly finding it more effective than other approaches. (Can post a link to details here if there is demand for it)

The next best approach is using a tool such as MaintainJ to trace code execution. This link documents that approach (when the author talks about aspects) and various other approaches, and having tried them all, coverage is what I've settled for.

sfk
  • 625
  • 1
  • 9
  • 17
  • I would like to add that MaintainJ captures the exact classes called and the runtime SQL statements for a use case. What else would you need to understand the code better? MaintainJ is the Best Modeling Product award finalist. Check the overview demo to get an idea of what you can do with MaintainJ - http://maintainj.com/userGuide.jsp?param=overviewDemo – Choudary Kothapalli Mar 05 '12 at 14:49
-1

Have you tried running javadoc on the code base? That would give you some idea if the structure (or lack of it) of the code. If you are really lucky design patterns might be mentioned in the comments.

There are lots of other tools for discovering class hierarchy - ClassCycle, Macker, JDepend etc.

Automatic detection of design patterns would be quite difficult I think, because a design pattern carries a lot of scope for variation.

Martin McBride
  • 498
  • 1
  • 4
  • 13