Book a Demo

Author Topic: EA for code generation  (Read 4248 times)

ChrisS

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
EA for code generation
« on: December 10, 2012, 10:48:34 pm »
Hello,
right now, we are thinking about using EA for the base for our code base. So we want to model our classes in EA and then generate the source code (C#). Since we already sitting on a large class model I imported it into the EA. Now I wanted to see if the generated code is the same like the existing one and I ran into some issues, which I'm not totally sure if the EA is able to support this at all:
- put classes with the same name/namespace (partial classes) into seperate files (folders)
- implemented code from the body of a method is not imported into the EA. Is there a way to tell EA to out some code automatically into a methods body (also also in property getter/setter)? (I found the in the "behaviour" section a field with "initial code" but that doesn't do the trick, it is somehow not filled)

Regards,
Christoph

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: EA for code generation
« Reply #1 on: December 11, 2012, 02:23:30 am »
It makes a difference if you're going to reverse engineer and keep the reverse engineered model in sync with the existing code base, or if you're trying to create your code base from scratch from the reverse engineered model.

The good news: Synchronizing usually works well, and will leave your source files from where they were imported.

There are some options where you can control the source directories (and file names) when code is newly generated.

The initial code has only effect when new code is generated. The field will not be filled with existing code from reverse engineering.

HTH
Günther

ChrisS

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: EA for code generation
« Reply #2 on: December 11, 2012, 02:29:22 am »
Thanks for your reply.
Well the situation is like this:
We have a quite large code base (~800 classes) which are implemented in C# and Java. Right now, we are sitting on a XSD from which the code is generated in both languages.
So what I am evaluating right now is if it is possible to use the EA in the future to generate our code.
Since we have some lazy loading initializers on some properties at least in C#, I'd like them to be written out in the getter of the property. Also there is a copy method sitting on every class which does the copy of the object for us.
Now this code should be inserted into the generated code too.

But I guess, since it's language dependant we would have to adapt the code generation template and insert it there right?

Edit: Also, the generated code is not touched on C# side. So all changes to the code would be done in EA
« Last Edit: December 11, 2012, 02:31:06 am by ChrisS »

Makulik

  • EA User
  • **
  • Posts: 400
  • Karma: +0/-0
    • View Profile
Re: EA for code generation
« Reply #3 on: December 11, 2012, 03:15:54 am »
Quote
Edit: Also, the generated code is not touched on C# side. So all changes to the code would be done in EA

As I mentioned: Changes made in the initial code field will be applied only on 1st generation. If you make changes there for a synchronized code base these will have no effect.

HTH
Günther

g.makulik

  • EA User
  • **
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: EA for code generation
« Reply #4 on: December 11, 2012, 05:23:38 am »
[Can't edit my previous reply from this account]

Another option might be to reverse engineer the XSD, manually create a PIM from this and transform to all other language representations (including the XSD) from this model.
Using EA9.3, UML2.3, C++, linux, my brain, http://makulik.github.com/sttcl/