Book a Demo

Author Topic: C++ forward/reverse engineering  (Read 3833 times)

jasbin

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
C++ forward/reverse engineering
« on: February 20, 2006, 12:08:10 pm »
I would really appreciate some of you sharing your experiences in trying to keep C++ source code syncronized with corresponding UML model using the forward/reverse engineer options. I am looking for experiences with fairly large real projects.

For myself, my project will ultimately have aproximately 500 classes and I see it really time consuming to model fully in EA. If a class has many methods, it will take a long time compared to reverse engineer. Some classes are already existing.

Many Thanks,
Jas.

jasbin

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: C++ forward/reverse engineering
« Reply #1 on: February 21, 2006, 07:05:08 am »
I didn't expect anybody to have successfully done round trip. Also, I read the opinions on the thread about reverse engineering java.

Now the question is are people successful in forward engineering C++? I mean, changes to be done in the model and source regenerated every time. I know a case where rose was successful, but developers were unhappy.

thomaskilian

  • Guest
Re: C++ forward/reverse engineering
« Reply #2 on: February 21, 2006, 10:41:46 am »
You will receive more replies about C++ fwd-engineering for sure. But you might want to read the threads you'll find with the keyword "roundtrip" here in this forum.

jasbin

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Re: C++ forward/reverse engineering
« Reply #3 on: February 21, 2006, 11:12:44 am »
Thanks Thomas. I had done that. Unfortunately not a whole lot of useful infomation there either.

Jaison.

thomaskilian

  • Guest
Re: C++ forward/reverse engineering
« Reply #4 on: February 21, 2006, 11:29:16 am »
The problem with just forward engineering is that people tend to not using the model but coding directly and then updating the model. This is a general problem discussed all over. EA offers some technique (MDG) to come around this problem, but (to my knowledge) this opens other trap doors. The last time I used fwd-engineering intensively I've been working with Rose. As far as I remember there is/was no difference to working with EA. You either could make the changes in the (ugly) UML tool editor, then fwd that and see the results. Or you worked for a certain time in the IDE and then propagated the changes back to the UML tool. Neither method was delighting. Depending on what you wanted to do you decided ahead for a method and happily model and code were in synch afterwards. Many times they were not :P Roundtripping was always some kind of Russian Roulette :(

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: C++ forward/reverse engineering
« Reply #5 on: February 21, 2006, 02:09:06 pm »
Since I work on it, I'm about as biased as you could get when it comes to EA code engineering, but I've had success with forward engineering C++.

How you need to work will vary if you choose to synchronise or overwrite files.

If you're synchronising you have the advantage that not everything in each file needs to be modelled, but EA won't maintain your #includes and your templates have to match what the parser imports or you can run into trouble.  You'll also find that modifying attribute/method signatures requires you to tell EA what to do.  This is also dependant on an option (Tools | Options | Attribute/Operations | On forward synch, prompt to delete code features not in model) although the need can be aleviated by enabling live code generation for your package.

If you're overwriting you need to model more, use more customized templates and there is probably more risk of losing work.  However, it is an advantage if everything is generated straight from the model.  My standard procedure for doing this is to create a diagram for each class to show its relationship to everything.  Dependencies for #includes in .cpp file, add an <<extern>> stereotype to define an extern.  I add the class and incrementally add attributes/links/methods and generate.  For generating the method body I cheat a bit.  After generating I'll write the method body in code, and reverse engineer it. (With the relevant option turned on.) That way when I next generate from the model all method bodies are generated as I last had them, and I don't need to use the 'initial code' field in EA.

The EA user group has my templates for generating namespace members (attributes/methods), I also have some modified templates for MFC specific generation and a bit of other stuff, I can put these up too if needed.

I've used both of these methods with success.  I'm generally only modifying one or two classes at a time, so the total size of the project doesn't make much difference.

I hope you'll find my comments useful.  If you have any more questions let me know.