views:

83

answers:

5

Hello everyone.

I am an engineering student, and deciding upon my final year project.

One of the many candidates is an online UML tool with code generation facilities. But I did not take compiler designing classes, so I am not much aware of the code generation techniques.

I want to know about the techniques that I should look to study in order to build something like this. If these techniques are as complicated as writing a compiler, then perhaps I will have to abandon this idea.

+3  A: 

Compilation is really the opposite of the kind of code generation you are describing, so I don't think you need to know how to write a compiler.

Code generation can be as simple as combining text strings or using templates, or as complex as using Reflection.Emit to create classes at runtime.

I would start with this Wikipedia article.

Robert Harvey
thanks, that was a nice head start. I think the concept of templates and template processor will help, specially if I want to support multiple target languages
Abhinav Upadhyay
A: 

I'm not sure exactly what capabilities your code generation will require, but the UML tools that I have used are not very sophisticated in their code generation.

Tools that I have used simply create files and drop your function names into them with arguments derived from the inputs. This would not require any understanding of compilers. Most of the difficulty would be in the user interface and how you store the data to make code generation easy.

Adam Shiemke
For getting started I am also looking for the most basic code generation as you mentioned, but I wanted to know if there are any standard methods or practices of doing this so that it may save me from reinventing the wheel and making my project more extensible, for starters I would try to support only 1 language like Java, with an extensible implementation I may be able to support other languages as well without much hassle.
Abhinav Upadhyay
+1  A: 

Most UML tools generate source code. The generation is normally quite a bit simpler than a compiler as well. For example, a class diagram will have a collection of data structures representing classes and links between those classes (inheritance). To generate output, you walk through the class objects, and for each you "print" out a representation of that object in the syntax of the target language.

Jerry Coffin
+2  A: 

The creation of an UML tool is a long term project. You need many to acquire different expertises which can not be known by just one member of the team. Your academic project is too ambitious.

An easy project which has never been done is to generate code from an activity or state diagram. You should not try to recreate the graphical editor because this is very very complex but only to take the xmi export and generate code from it using a xml parser. This would be a good 6 months project for your thesis :-)

+1 for that new idea :).
Abhinav Upadhyay
A: 

You can just find that here: http://yuml.me and http://askuml.com

Rebol Tutorial