Book a Demo

Author Topic: Should I try to generate all my C++ code directly from my EA model?  (Read 5961 times)

dandrus

  • EA Novice
  • *
  • Posts: 9
  • Karma: +1/-0
    • View Profile
I've recently been put in charge of a project that is using IBM Rational Rhapsody such that all of the C++ source is generated (one way or another) from a UML/SysML model.  There was plenty of external python scripting that works around various limitations by fixing up the model via the Rhapsody COM interface.

My intention is to replace Rhapsody with EA.  The open architecture of the EA Code Template Framework (CTF) is inspiring since much of the complexity with the current development flow was caused by the inability to modify the code generation of Rhapsody.

I'm curious to hear people's advice on whether I'm headed down a road where EA will bring a different but equally complicated set of challenges...

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13427
  • Karma: +569/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Should I try to generate all my C++ code directly from my EA model?
« Reply #1 on: December 22, 2016, 03:48:12 pm »
I think generating code from a UML model is inherently complex, regardless of the tools you use.

When given the choice starting from a blank slate I think I would prefer to write my own code generator rather then use the MDA templates in EA.
I feel those that hard to read/understand and still often lack the flexibility you have when rolling your own.
But in this cases there might already be a lot of existing templates that you can use for your purpose, which could be a game changer.


Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Should I try to generate all my C++ code directly from my EA model?
« Reply #2 on: December 22, 2016, 09:36:57 pm »
I'm with Geert and as I mentioned in another thread of yours, you should be reluctant when trying to generate code from UML models. I once had some success with Rational Rose, but the hooks they placed in the generated code were always a stumbling stone (in that changing them accidentally resulted in unpredictable results and that they simply  looked ugly). Trying to use EA as IDE failed (I tried that but gave up soon). It's much better to make a break between UML design (in EA) and coding (in an IDE).

q.

dandrus

  • EA Novice
  • *
  • Posts: 9
  • Karma: +1/-0
    • View Profile
Re: Should I try to generate all my C++ code directly from my EA model?
« Reply #3 on: December 23, 2016, 07:19:40 am »
Thanks Geert/qwerty.  One of the main motivations is to adhere to the model based engineering (MBE) principle "the model is an executable spec".  There is also a grand vision of having a hardware model generate first into C++, then loosely timed SystemC, then ultimately into VHDL. 

But putting the grand vision aside, if the model stops at the interfaces, can it really survive as a "golden spec"?  Our current process ensures that changes made by developers are reflected in the model because the flow doesn't support them just changing the code directly.  If the developers are implementing the code in an IDE, how do I maintain consistency between the code and the model?  If the model becomes irrelevant/outdated once the development is started then there is no requirements traceability and thus no MBE...

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: Should I try to generate all my C++ code directly from my EA model?
« Reply #4 on: December 23, 2016, 07:33:48 am »
As mentioned, it is a break. But a necessary one. Coding in EA is a PITA, believe me. You want to debug your code. You want intellisense. You want a ripe IDE. Without that, any coder is unhappy and gone before you can say, "but...". So introduce rules that ensure coders and modelers work hand in hand and use EA as medium for information interchange. That's perfectly possible, but requires some strictness for all stakeholders.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13427
  • Karma: +569/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Should I try to generate all my C++ code directly from my EA model?
« Reply #5 on: December 23, 2016, 06:50:48 pm »
There are some successful stories out there that generate 100% of the code out of enterprise architect.
Most of them are from the embedded world, where the coding freedom is very limited, and deploying and testing the software is a big deal that involves burning chips and stuff like that.
In those limited environments I've seen cases where all of the code is generated from the EA model, and even all of the testing and simulation is done in EA before a single chip is flashed.

In the other success stories I've seen you'll have to put a lot of effort in the code generator, that will be specific for a certain technology stack, and a specific way of working. If you have a software factory that that use the same method in numerous products/projects then there might be a positive business case. (see smart use cases from Sander Hoogendoorn for an example of such a code generation method)
If it's just for one project then you are probably better off writing the code by hand as it will be faster then writing the generator (or even the templates) needed to get the code you need for your project.

I'd love to be to be involved in a project that does 100% code generation from EA, but I haven't seen a positive business case for it yet.
Most of my clients use EA for Business and Functional analyses and still write code by hand using a traditional IDE. As long as you make sure that your EA model are on a different (higher) abstraction level then the code you are good. Just avoid modelling the code in EA if you are not going to generate that code from EA.

Geert


Helmut Ortmann

  • EA User
  • **
  • Posts: 970
  • Karma: +42/-1
    • View Profile
Re: Should I try to generate all my C++ code directly from my EA model?
« Reply #6 on: December 23, 2016, 08:00:38 pm »
Hi,

I agree with Geert. I would also like to participate in such a project.

The idea is great. Keep code and model in sync and everything is fine. It works fine for limited scopes like State Machines or DSLs (Domain Specific Languages).

Also be aware: Modern IDEs like Eclipse or Visual Studio are comfortable to use. They are doing a great job to implement the problem at hand.

If you model to generate code, there is the risk that your model is more to produce good code than to understand your problem at hand. Then you deal with a complicated environment and a model that is mostly made to generate code.

Well, there is a solution like MDA (Model Driven Architecture) or so. You develop an analysis model and then (generate) an implementation model. Be aware: This is also no easy job like many Powerpoints suggest.

To make it short: Think carefully about a general purpose code generating environment. In most cases, you'll need management approval to cover risks, costs, etc.

Kind regards,

Helmut
Coaching, Training, Workshop (Addins: hoTools, Search&Replace, LineStyle)