Book a Demo

Author Topic: Code generation to multiple langages  (Read 4865 times)

shiroryu

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Code generation to multiple langages
« on: August 24, 2018, 07:35:52 pm »
Hello !

From a single UML data model, I am trying to generate to C#, Java and C++. I am using EA Pro v14

However, because the target langage and filename extension properties are defined per class, I need to change theses properties on each class each time I need to change the target langage for generation (and I have many !).

I did not find any possibility to do  change the target langage for generation and filename extension at package-level
I did not find eather a way to do multiple selection of classes and change the target langage and filename extension at once.

Any idea ?

Regards

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Code generation to multiple langages
« Reply #1 on: August 24, 2018, 09:16:54 pm »
If you have multiple target languages you should create packages with derived classes for each individually since that would model your reality more appropriately.

If you insist on singles classes you might write a script or use the Advanced/Update Package Status to change the language in that package globally.

q.

shiroryu

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Code generation to multiple langages
« Reply #2 on: August 27, 2018, 05:04:13 pm »
Thanks for your answer.

I already have separate packages for each language. My concern was how to change the langage target for the whole package at once, and not manually file by file.

I finally found a way with the "Apply Tranformation" command !

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Code generation to multiple langages
« Reply #3 on: August 27, 2018, 06:57:00 pm »
The way model driven approach is intended to work is you have one platform independent model (PIM) from which you can transform to multiple platform specific models (PSM) and from those models generate code. The platform Specific Models are technology specific such as Java, C#, XML, DDL

For example with one PIM you would transform to several PSMs and then from those generate code.
PIM-> PSM (C#)-> C# code files
PIM-> PSM (Java) -> Java code files
PIM-> PSM (C++) -> C++ File
PIM-> PSM (DDL) -> DDL File to create a DB schema.
etc...

The language for all the elements in the PSM should be set in the PIM -> PSM transformation.

Sounds like you are trying to start with a data model then generate several code files which isn't the correct way. If your trying to change the language then your probably not doing it correctly.

There are plenty of books out there for you to read on the topic of Model Driven Development and Model Driven Architecture.

Hope that helps.
« Last Edit: August 27, 2018, 07:04:52 pm by Sunshine »
Happy to help
:)

shiroryu

  • EA Novice
  • *
  • Posts: 8
  • Karma: +0/-0
    • View Profile
Re: Code generation to multiple langages
« Reply #4 on: August 27, 2018, 09:32:34 pm »
Actually, our current baseline is a C# datamodel with no UML to start with.
This is why I initially did initialize the PIM from the C# code base.

At some point in time, we will do a PIM-first developpment and generate the C# (and other langages) from a PIM.


Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Code generation to multiple langages
« Reply #5 on: August 28, 2018, 06:24:39 am »
Actually, our current baseline is a C# datamodel with no UML to start with.
This is why I initially did initialize the PIM from the C# code base.

At some point in time, we will do a PIM-first developpment and generate the C# (and other langages) from a PIM.
In that case you should do C# to PIM transformation. Then you have a path for creating the other PSM.
Happy to help
:)