Author Topic: Generate Python code from package  (Read 7303 times)

EA_enthusiast

  • EA User
  • **
  • Posts: 172
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Generate Python code from package
« on: December 30, 2020, 08:08:31 am »
Hello, EA experts,

I am trying to generate a Python code from a package but I faced 2 issues.

Question 1: how can I make the model generates the code in Python?

When I go to
Start > Desktop > Preferences > Preferences > Source Code Engineering > <language name>
or
Configure > Model > Options > Source Code Engineering > <language name>

I do not see an option to select Python (Please see the screenshot)

https://ibb.co/0XTzDgq

Question 2: when I go to Develop > Source Code > Generate > Generate All

I do not see all the classes under the package, listed in the dialogue box. Did I do something wrong? (Please see the screenshot)

https://ibb.co/2WwHjDC

Thank you so much!
Mo
« Last Edit: December 30, 2020, 09:32:11 am by Mo »
Thank you to all the contributors who spread their knowledge and experience!

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Generate Python code from package
« Reply #1 on: December 30, 2020, 12:08:16 pm »
For the first question, select the 'Configure > Model > Options' ribbon option. That displays the 'Model Options' dialog. Click on the 'Source Code Engineering' item, and on the 'Code Generation' page set 'Python' in the 'Default Language for Code Generation' drop-down field.

For the second question, I don't know off hand what you should or should not see in the dialog. I can't see the screenshot and I don't know what object you selected or whether the option is appropriate to that object.
Best Regards, Roy

EA_enthusiast

  • EA User
  • **
  • Posts: 172
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: Generate Python code from package
« Reply #2 on: December 30, 2020, 12:33:44 pm »
Hello, RoyC,

Thank you very much for your response! That solves my first issue.

I included a link to the screenshot of the project browser and the code generation dialogue box. It shows the selected package includes several classes but only one class was added to the dialogue box for code generation.

I would appreciate to take a look at the screenshot and let me know what you think.

https://ibb.co/2WwHjDC

I don't think there's an option to embed an image to the message body.
Thank you to all the contributors who spread their knowledge and experience!

RoyC

  • EA Administrator
  • EA Practitioner
  • *****
  • Posts: 1297
  • Karma: +21/-4
  • Read The Help!
    • View Profile
Re: Generate Python code from package
« Reply #3 on: December 30, 2020, 12:59:39 pm »
Unfortunately I cannot open any links to external sites in Forum posts.

All I can say is that when I select a Package containing Classes and then select the Generate All option as you did, all the Classes in the Package are listed in the dialog, selected (highlighted in blue) for code generation. I don't know why your experience is different to mine.
Best Regards, Roy

EA_enthusiast

  • EA User
  • **
  • Posts: 172
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: Generate Python code from package
« Reply #4 on: December 30, 2020, 01:05:58 pm »
Thank you again, RoyC. This is exactly what I need help to figure it out.

I hope another EA expert would be able to open the link and figure out what's going on.

Mo
Thank you to all the contributors who spread their knowledge and experience!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Generate Python code from package
« Reply #5 on: December 30, 2020, 09:53:35 pm »
You probably should think twice whether to generate code from an UML tool. While UML is nice to sketch concepts, any tool (that I know) fails when it comes to code. There's a huge difference between coding and designing and you always will encounter a gap between both. At first it sounds nice to have to code in the UML tool. But in the end it's only a PITA. I don't have a good solution, but having code in EA is nothing you want on a long term. Good luck with your attempts, though.

Btw: I use Wingware as Python IDE. Pretty cool and affordable. All bells and whistles included (and you need most of them).

q.
« Last Edit: December 30, 2020, 09:56:05 pm by qwerty »

EA_enthusiast

  • EA User
  • **
  • Posts: 172
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: Generate Python code from package
« Reply #6 on: December 31, 2020, 04:21:09 am »
Hello, q.

Thank you very much for the advice. I started to realize that when I came across some older posts in which you and other EA experts raised concerns on generating code from EA.

It seems that the concept of Model Based Development is unattainable.

With that said, I am wondering how can I establish a close synchrony between my model as an architect and the code generated by the developer?

Mo
« Last Edit: December 31, 2020, 05:34:15 am by Mo »
Thank you to all the contributors who spread their knowledge and experience!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Generate Python code from package
« Reply #7 on: December 31, 2020, 06:23:08 am »
That's walking on a razor's edge. (Just my opinion here) Designing in UML is a nice thing. You even get the coders hooked on that when it comes to planting the architect's ideas in their heads. They can go off and produce code that's most likely what the architect (expressing the end user's ideas) had thought. But once the code is up and running hell 's breaking loose. You start change cycles which tend to fall off into all directions. Code optimization here, customer change there, design update at another place. There's no good way to get all that under the hood. If you're lucky, you have a couple of coders which follow you documenting their changes. But usually that does not happen. Who ever tried to make a good documentation in form of SDs of what ever he coded knows what I mean. You fight with arrows not staying where they should. You have methodological shortcomings or simply you're under pressure to implement an urgent CR. Being in the role of the architect to keep it rolling means you have to foresee those hindrances and provide support or work arounds. Long story short: you need a lot of experience and even more luck with your team. Guess why there are so many different methodologies out there all claiming they are the absolute truth.

q.

EA_enthusiast

  • EA User
  • **
  • Posts: 172
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: Generate Python code from package
« Reply #8 on: December 31, 2020, 06:58:50 am »
Again, thank you for your advice q.

I guess after what you said, I should not try to keep the model and the code in lockstep as I originally envisioned. It does not seem to be practical and it seems to be a time-consuming task.

It seems that the "main" use of the model is to to plant the system's idea in the coders' heads (a way to ensure we are on the same page). Also, it seems that trying to rigorously maintain the model as the single source of truth (through continious sync with the code) is very challenging.
Thank you to all the contributors who spread their knowledge and experience!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Generate Python code from package
« Reply #9 on: December 31, 2020, 08:24:21 am »
Exactly. Well, I sort of got a dev team running for a while in a project. Thanks to some very enthusiastic guys helping me on my way. Probably in most cases it does not work so well. I read a lot of failure stories on Stackoverflow. Being lucky is probably just a question of "being lucky". I still think that user stories and all those business aspects are well kept in UML, though getting stakeholders on track is a different story. But these stories are more stable (usually) and often not well documented. So if you manage that part you can really call yourself "being lucky".

q.

EA_enthusiast

  • EA User
  • **
  • Posts: 172
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: Generate Python code from package
« Reply #10 on: December 31, 2020, 08:44:26 am »
Thanks a lot, q. for great insights.

Based on your advice, I will save my time/energy to capture the structural and behavioral aspects of the system (to achieve the user/business objectives) without worrying about continuous sync with the code. Hopefully I can manage this part well to call myself "being lucky" :)
Thank you to all the contributors who spread their knowledge and experience!