Book a Demo

Author Topic: Code Generation  (Read 31081 times)

Daniel Siegl

  • EA User
  • **
  • Posts: 42
  • Karma: +0/-0
    • View Profile
Code Generation
« on: April 01, 2011, 12:53:18 am »
My Opinion:
UML and codegeneration ==> in 2011 it is all about forward engineering - roundtrip has to many disadvantages

What's yours?

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Code Generation
« Reply #1 on: April 01, 2011, 07:08:01 am »
I had the same idea some years ago. However, most coders are rarely modelers  :(

IOW: round trip is still alive. I'm waiting for the ultimate UML/IDE which is not yet seen at the horizon.

q.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Code Generation
« Reply #2 on: April 01, 2011, 08:32:18 am »
Out of curiosity, what would you expect in your ultimate UML/IDE tool?

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1353
  • Karma: +121/-10
  • Its the results that count
    • View Profile
Re: Code Generation
« Reply #3 on: April 01, 2011, 09:59:55 am »
If you have 100% code generation then yes forward code generation is the way to go. However in most cases that isn't possible/practical so inevitably hand coding takes over and the changes happen. Keeping the model and the code in sync requires some discipline and extra effort, ultimately leading to time-pressured projects forgetting about updating the model and just getting the code to work.

On the other hand looking at hundreds of thousands of lines of code can be difficult and reverse engineering it into a model helps the learning of unfamiliar code so it still has its uses.

So until a tool provides significant productivity gains (i.e. x10 or more) and the ability to generate 100% code I think you'll always need reverse engineering.

As a side note in 1990 when I first started using code generation from modelling tools I thought by the year 2000 we would be using models to generate 100% code. How wrong I was  :'( .
May be in another 10 years ;D
Happy to help
:)

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Code Generation
« Reply #4 on: April 01, 2011, 11:26:52 am »
Quote
Out of curiosity, what would you expect in your ultimate UML/IDE tool?
Don't open the flood gates!

Haven't you guys had enough water in Victoria? :)

If you were to collate the suggestions we users have provided and implemented them, you start to come pretty close...

Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Code Generation
« Reply #5 on: April 01, 2011, 07:40:18 pm »
Yep. If I'd started to philosophize about an UML/IDE I'd need a book to write it down. If I had the chance to play around like that project manager in Tom DeMarco's Deadline...

q.

Daniel Siegl

  • EA User
  • **
  • Posts: 42
  • Karma: +0/-0
    • View Profile
Re: Code Generation
« Reply #6 on: April 01, 2011, 07:50:33 pm »
Hello,
Here a short Video how it can be handled for Embedded:
http://www.youtube.com/watch?v=UJHI7VC_apg
BR
Daniel

Roman Bretz

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Code Generation
« Reply #7 on: April 01, 2011, 10:19:39 pm »
It depends on the platform and on the language basically. In general as long as UML-editor and IDE only share the code and not the model in behind, i agree - the complexity is too high. But for C# or Java an integrated solution is possible i guess.

But in my opinion the roundtrip engineering basically misses the point. The real profit of the code generation is the usage of higher abstraction level of UML/Model. As far as I start reworking the generated code i lose the advantage of UML/Modeling. That's the reason why roundtrip engineering will never be mainstream.

The basic problem of current tool chains is not the missing of reliable and usable roundtrip solutions but rather inhomogeneous abstraction level during development life cycle, or with other words: nobody would use C# if he has to debug assembler code after that. The gab between these two worlds overbalances the advantages of MDD.

As simple as that
« Last Edit: April 01, 2011, 10:23:20 pm by rbretz »

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Code Generation
« Reply #8 on: April 02, 2011, 02:54:46 am »
I'd go further (just from my experience): UML is regarded just as add-on. PMs tell "we absolutely need it" but they do not act accordingly. In fact they tell their developers "code it first and if time permits document it (with UML) later then". So that makes the demand for round trip. I usually accompany in modeling "attempts" until the time where money is out. After that they go on "the classic way". What a waste of money, but as long as I can get a part of the budget....

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Code Generation
« Reply #9 on: April 05, 2011, 01:59:28 pm »
In fact, I think there are a number of challenges left before code generation can really pay off.

- 100% code generation:
This is crucial. A 100% should mean 100%, not 99.95% or something like that. The moment you need to "hand code" a part then code generation has lost.

- Abstraction levels
As indicated before, we need abstract models without all of the technical details to understand the big picture. I think this will only work if we have automated transformations that transform the abstract level (PIM) into a technical model (PSM). Again 100% transformation is the key to success.

- (GUI) layout changes feedback.
Especially when dealing with GUI's you may want to manually change the layout of the screen to make it more user-friendly (or even just better looking). These cosmetic changes should somehow be stored in the model so the layout work isn't lost in the next generation cycle.

I'm pretty sure "hand coding" will be a thing of the past in some distant or near future. I guess it will have the same status as hand coding "assembler" these days.
Yes, you CAN still hand-code assembler, but it is only done by a few weird specialists, and only if REALLY needed. All normal people let the compiler create the assembler stuff.

I'm not going to make any predictions on when this day will come, but I'm pretty sure we'll need to address the challenges listed above if we are ever to reach that state.

Geert

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Code Generation
« Reply #10 on: April 06, 2011, 09:24:13 pm »
OK, let's start at the very beginning.

UC1: Go to Grandma's House

User: Invoke
System: Transport user to Grandma's house

Hmmm, I don't think we're quite there yet.
So we need at least 1 architect, a couple of engineers and a sprinkling of managers of various species (and a wolf or two, the odd huntsman and a whole bunch of environmental stuff).

Hang on, does the user have a "basket of goodies"?

Bugger! Optional parameters.

No, its OK, the archit-wreck says there are no options in the UC.

[Generate]
.....................................

Test
Deliver
Install
Wait

"Ring, ring!"
"Hello, Helpdesk Harry speaking.."
"Hello, I need to take a basket of goodies! How can I make the system do that?"

...

"Have you tried rebooting the system?"


 :-X

yours very sincerely
YouKnowWho


"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +397/-301
  • I'm no guru at all
    • View Profile
Re: Code Generation
« Reply #11 on: April 07, 2011, 02:01:33 am »
IOW: your concern is that code gen is not "agile" enough?

q.
« Last Edit: April 07, 2011, 02:01:53 am by qwerty »

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: Code Generation
« Reply #12 on: April 07, 2011, 10:48:32 pm »
Quote
IOW: your concern is that code gen is not "agile" enough?

q.

No, I'm saying that UML is not adequate enough to provide a basis for the ultimate in code generation.  If it was, then the fundamental precepts would provide enough in the definition of "use cases" such that the system could be "mechanically" devised.  

Geert says "Yes, you CAN still hand-code assembler, but it is only done by a few weird specialists, and only if REALLY needed. All normal people let the compiler create the assembler stuff."  

Beware, my friend, beware!  Looking into my somewhat cracked crystal ball I can see a time when "Yes, you CAN still hand-draw class structures, but it is only done by a few "weird specialists", and only if you really need to HUMOR THEM.  All normal people let the the modeling tool create the conceptual system structure."

But, and I mean BUT!, there is a dimension to the whole modeling ethos that is being ignored/sidestepped in this discussion.  If it were possible to construct a "system-to-generate-systems" then it must start at the first and fundamental concepts.  That is, in the case of UML, the use case. Obliquely, I was trying to say that it is a case of "physician, heal thyself!"  The sheer idea of humankind's ability to devise a universally coherent "round-trip" code generator, when we can't even devise a coherent definition of what the "damn code is supposed to achieve in the first place" is somewhat like trying to design a brick that could build the Winchester Cathedral, by itself so to speak, so we didn't have to help, or "work" so to speak.

Or, in other words, there are more substantial problems within UML and therefore by extension, EA, that need to be solved before the answer to "how come when I click on generate and then on import and then on generate and then on ...".  So to get back to Geert, yes there will always be a need for assembler coders, just as there will always be a need for UML expert practitioners, if not then Dog help us!  We'll all be out of a job.

 ;D


Well Paolo, you did warn them  ::) !
« Last Edit: April 07, 2011, 10:49:33 pm by sargasso »
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Roman Bretz

  • EA Novice
  • *
  • Posts: 16
  • Karma: +0/-0
    • View Profile
Re: Code Generation
« Reply #13 on: April 08, 2011, 05:43:13 pm »
IOW: thanks a lot for a hint - now i realized a fact i basically knew all the time but wasn't really aware of it.

It's on of the biggest advantage of UML and obviously an issue for the most UML user at the same time:

UML uses nearly the same constructs / elements for describing
    the problem domain and the solution domain.

But in case of use cases it's clear, that type of diagrams shall be only used for describing the problem domain. And in general (99%) the problem has only indirectly to do with the solution.

How that?

How many solutions do you can provide for one simple use case (problem to solve): user wants from point A to point B??? I guess thousands. The job of the architect is to consider the non-functional requirements (and the customer is typically not aware of them) to provide an solution optimal for the customer.
By the way what is the difference between an architect and a key developer? ;) You find the answer in the explanation above.

OK, back to the thread topic :)
In case we seriously intend to discuss the roundtrip engineering (it's basically the topic) we have only to consider the solution part, that means somebody understood the problem and designed a system intended to be executable.
« Last Edit: April 08, 2011, 05:47:35 pm by rbretz »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Code Generation
« Reply #14 on: April 08, 2011, 06:02:00 pm »
Quote
[size=18]...[/size]
In case we seriously intend to discuss the round-trip engineering (it's basically the topic) we have only to consider the solution part, that means somebody understood the problem and designed a system intended to be executable.
Well if we're just talking about the round-trip process...  Then we're talking about taking a (in OMG terms) a PSM, generating an artifact into the real world then reverse engineering the artifact into a PSI (my invention - the Platform Specific Implementation.  The PSM defines the design model the PSI what is in the real world.)  Comparing the two (since they are at the same level of abstraction) and confirming there are no differences.

We can't even do that...

There's more I want to add, but let's get some agreement on this much.

Paolo
« Last Edit: April 08, 2011, 06:03:17 pm by PaoloFCantoni »
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!