Automated Code Generation
The Fastest Way to Write Software?
By
May 6, 2002
Thanks to and from Javelin Software
This article is divided into the following pages:
1. Introduction
2. What is a Code Generator?
3. How Do Code Generators Work?
4. Types of Code Generator
5. Advantages & Disadvantages
6. Generators and Agile Projects
7. Conclusion & References
Introduction
Automated code generation is not a new concept,
although it has seen relatively little recognition until recently.
Recent changes in the way software is developed may cause an upsurge
in the use of code generators as a way of bringing enterprise software
to market extremely quickly.
Of these recent changes, the driving factor is that enterprise development has almost become a "paint by numbers" exercise. For example, the advent of EJBs has brought with it a proliferation of enterprise design patterns and best practices. This is no bad thing - increased use of design patterns can only lead to more robust code and faster time to market.
Meanwhile, the programmer is left to concentrate on the parts of the system that matter - the business logic, the very reason that the application is being written. The "guts" of the system are left to the server vendors to implement, and are supplemented with proven design patterns.
The reality, of course, is that enterprise code has suddenly become rather tedious to write. EJBs are time-consuming. Nowadays, programming is a contradictory mix of deep thought and menial "drudgery". The drudgery tends to involve repetitive tasks, such as producing EJBs (or 2-tier business objects) for a large number of database tables.
To implement a system, the programmer must face the chore of creating an endlessly repetitive number of session and entity beans. When that project is finished, the programmer must start all over again on the next venture.
This seemingly endless cycle of repetitive coding led me (and many others) to wonder: aren't repetitive tasks what computers are supposed to be good at?
Of course, this is where code generators come in.
>> Page 2 (What is a Code Generator?)
Talkback:
Post a new message
Message Index: Been doing this in Perl for awhile Peter J. Schoenster softwarereality@errorcode.com
Code generator evaluations? Rik rvanbruggen@yahoo.com
Code generators are career limiting Kevin kevjv@hotmail.com
Issues with code generators andy anon@anon.com
Pollen UML-GUI Designer Laforets Luc_Laforets@e-CompanionSoftware.com
Do you know GeneXus? Chengue chengue@bolso.com
"In Context" code generators... Paul M. pm22@yahoo.com
Use XSLT for code generation Soumen Sarkar sarkar_soumen@yahoo.com
Give me a HAND!! zhukuipop zhukuipop@elong.com
Nice article.. but nothing about parser generators? Hugh hughdoar@hughdoar.homechoice.co.uk
Code generation of JUnit test cases situ sry@hotmail.com
Code generation on JUnit Robin Sharp robin.sharp@javelinsoft.com
AutoGen's been around for a while now Bruce Korb autogen-users@lists.sf.net
Coad Series Book ?Better Software Faster? -- Free Chapter Download KMcKnight moreinfo@togethersoft.com
New release of Model Driven Code Generator anthony mowers http://www.amowers.com
How Can I choose Best Code Generators ???????????? Amir Shokrpour@dana-insurance.com
Multi target generations with Model-in-Action Fred Madiot fmadiot@mia-software.com
Test cases demetrius johnson deejay3_0@yahoo.com
In response to issues with CGs Richard
Make a Code Generater Ben comptyweb@yahoo.com
Code Generators Lee Leedare@talk21.com
Code Generation Website Mark Dalgarno editor@codegeneration.net
GIS APLICATIONS AND GENEXUS Daniel Romero daniel.romero@pett.gob.pe
Code Generators are workarounds... kevin cline kevin.cline@gmail.com
uptdock ijfvwy lxedamktq fyme pevg@mail.com
uptdock ijfvwy lxedamktq fyme pevg@mail.com
uptdock ijfvwy lxedamktq fyme pevg@mail.com
The Messages: Been doing this in Perl for awhile Hi,
As a Perl programmer I often write scripts to automate trivial tasks. First thing I do when creating a new web app is brainstorm. I try to glean what the app is supposed to do. I then put together a database and list of functions and then autogenerate what you can see here:
http://www.memphisprogrammers.com/admin/
I then have the designers apply their theme to the generated html templates and then work with the client so they can begin to touch and feel. But that's the end of my code generation and other than the shell which I create, I have to really write all the code by hand after that.
Peter J. Schoenster softwarereality@errorcode.com MidSouth, USA Thu May 16 16:51:44 BST 2002
Code generator evaluations? Hi
I read your article with extreme interest. It is a topic that is far too ofter understressed, especially in a J2EE environment. I personnally had the chance to see the Sygel WMEE tool in action a couple of times, and I was VERY impressed. They let you 'draw' your system model in your UML tool of preference, and a few seconds later you have a working baseline architecture for you to build on. Plus: thanks to their code merging tools, the generated code fits in super-smoothly witth your self-developed business-logic.
Now an interesting question: have you ever had the chance to compare some of the generator tools that you mention, and possibly even evaluate them?
Like you say, these types potentially have a lot of specific pros and cons that make it very unlikely that there is a one-tool-fits-all-projects tool. But it could be useful to have some sort of evaluation matrix to compare some of these niche players ...
Cheers
Rik Rik rvanbruggen@yahoo.com Antwerp, Belgium Fri May 17 19:31:40 BST 2002
Code generators are career limiting Hello,
I have some additional items for your disadvantage list. I guess it may depend on your viewpoint though. My current experience with a proprietary code generator is that it will doom my career. The code generator does its thing by reading UML models. The resulting code is a skeletal set of business objects. The only thing to do is fill in any business logic in the methods and properties. This reverts the developer experience to a tedious, boring job with no future. I will get very good at language syntax but nothing else. The proprietary nature gives you no valuable experience you can use elsewhere. You are stuck and at the mercy of your employer. The employer probably loves it, but I will probably be flipping burgers in a few years unless I look for work elsewhere.
Kevin
Kevin kevjv@hotmail.com CA, USA Fri May 31 21:18:53 BST 2002
Issues with code generators While I agree that code generators can be a good thing (and also, that Perl is an excellent language for writing tactical generators), IMHO the following caveats apply:
* Vendor-provided code generators will almost certainly lock you into that vendor; something that standards were supposed to protect us from (esp. Java!)
* Although full round-trip engineering looks like a nice idea (i.e. just change your meta-data and then re-generate the code, if you want to change the way you do something) this is often not possible in those cases where you have to apply manual changes to the code following the code-generation step.
* Code generation often becomes an end in itself and a substitute for thought, leading to poor design and a high degree of code-bloat. It's just SO easy to just generate another dozen or so classes, when a re-think of the problem could provide a much more generalised solution to the problem in hand, using a fraction of the number of classes required by the CG approach.
Thanks for a great site! andy anon@anon.com London, UK Mon Jun 17 16:08:03 BST 2002
Pollen UML-GUI Designer I'm Luc Laforets, the designer of a user interface code generator named "Pollen UML-GUI Designer" http://www.e-companionsoftware.com/. Pollen generates most of the presentation layer of software relying on both static and dynamic UML models. Generating the user interface warranties GUI consistency and early validation of the UML model by final users. It also facilitates internationalization and promotes strictly layered architecture (presentation/business/data). On small-medium projects Pollen can even generate up to 100% of the software (I manage my personal wine cellar with this kind of program).
In your article you have pointed out that vendor lock-in is one of the most important risk of CGs. You are right. To avoid that, Pollen only relies on standards : UML for modeling, Pure Java Swing for code (C# will be available soon). The runtime source code can also be provided to customers.
Thank you again Matt for this excellent article about code generation. I hope your lecturers will enjoy with Pollen.
Laforets Luc_Laforets@e-CompanionSoftware.com Paris, France Fri Jun 28 07:16:46 BST 2002
Do you know GeneXus? GeneXus it's a tool that can generate code for a lot of languajes (VFP, VB, Java, C#, RPG, Cobol, C). Also it's manage the database doing the normalization for you... It's a very useful tool... Check it out here: www.genexus.com Chengue chengue@bolso.com Miami, USA Wed Jul 03 14:08:31 BST 2002
"In Context" code generators... Pretty interesting stuff. Fundamentally I agree that there are a few things awry with the way people build software applicatons:
1. There is too little automation/code-generation: developers are constantly coding very similar application fragments (e.g. CRUD operations etc).
2. Since applications are hand coded, it becomes really hard to change trivial things. e.g. a new column in a database is added - this requires changes to the data access layer, the ui layer (view and data input), error checking etc.
Our group tried a number of 'higher level' development tools, before settling on the 'Factory' by Bowstreet software. We can now typically create applications about 10 times quicker than traditional means. Generic software robots("builders") allow one to write "in context" code generators. Defintely worth a look.
- Paul
Paul M. pm22@yahoo.com Chicago, US Tue Aug 06 03:51:23 BST 2002
Use XSLT for code generation You may take a look at a newer paper on XSLT based code generation:
Model driven programming with XSLT by Soumen Sarkar.
XML Journal, August 2002, Volume 3, Issue 8
http://www.sys-con.com/xml/pdf/trees.pdf
Summary: Take a deep look at use of XSLT for code generation (from XML models). You will be rewarded with tremendous productivity gain in your software development projects. Soumen Sarkar sarkar_soumen@yahoo.com Fremont, CA, USA Thu Sep 05 21:06:37 BST 2002
Give me a HAND!! EveryBody: nice to take part in this topic.I am a graduated student in China.now I am interested in xUML,unfortunatedly,In China,No material can be found.I know some books about xUML in English.but they are so expensive that I can not offer them and perhaps I will have no chance to study in it.I sinerely hope somebody would help me and provide some e-books about xUML or some materials to me.My E-Mail is :zhukuipop@163.com my Addr:China,LiaoNing province,DaLian Maritime University.Dorm 10,Room 212,ZhuKui
zhukuipop zhukuipop@elong.com DaLian, China Fri Dec 13 06:53:02 GMT 2002
Nice article.. but nothing about parser generators?
nice, but then, this is a topic i'm interested in :) just cutrious that there was no mention of yacc and the like? ~hugh
Hugh hughdoar@hughdoar.homechoice.co.uk London, UK Fri Jan 17 16:26:07 GMT 2003
Code generation of JUnit test cases Hi,
I'd like to know the experiences of people with regard to automatic(?) code generation of JUnit test cases. I'm refering to projects which do not work the XP way, but still would like to have high % of unit testing (meaning, unit test code is done at the end), and to projects that need to deal with legacy code.
Specifically, (a) What has been your experience with tools which auto-generate test cases that give a good % of code coverage when tested with code coverage tools, such as Clover?
I've worked with - open source options mentioned in http://www.junit.org/news/extension/testcase_generation/index.htm, but these only generate the skeleton of the methods
- JTest, which generates pre-determined values for primitives, and does nothing about Java value object classes, and expects the programmer to add in the "other" test cases - which in effect turns out to be a lot.
I guess what I'm looking for is a tool that "understands" the code and generates unit test cases for all the branches and conditions in the code, in order to achieve maximum code coverage. Is there any such beast out there? :)
(a1) Has anyone worked with TogetherJ/XPTest (http://www.extreme-java.de) for generating JUnit test cases? I didnt see too much of high-lighting on the TogetherSoft site on this one... What have been your experiences?
(a2) On a related note, does anyone know of XMI-compatible JUnit generators, which would remove the dependency on the UML tool?
(b) What has been your experience with mock objects? Have they been too cumbersome a process for the average project size (say, 100 classes, with 10 value object classes)?
(c) Building functional test cases: I've heard of JFunc; what are the other options, and how do they compare?
Thank you very much, situ situ sry@hotmail.com Bangalore, India Fri Jan 31 07:44:12 GMT 2003
Code generation on JUnit We use a code generator to create test cases for JGenerator (www.javelinsoft.com/jgenerator). So we're testing code generated code with code generated test code.
We use a descriptor file called the gym in which we have put every permutation of every type of data. This the first of many tables.
readTable.1=TypeValue readColumn.TypeValue.0=typeValueKey INTEGER PRIMARY KEY readColumn.TypeValue.1=longType BIGINT NOT NULL readColumn.TypeValue.2=fixedBytesType BINARY(10) NOT NULL readColumn.TypeValue.3=booleanType BIT NOT NULL readColumn.TypeValue.4=charType CHAR(10) NOT NULL readColumn.TypeValue.5=nCharType NCHAR(10) NOT NULL readColumn.TypeValue.6=dateType DATE NOT NULL readColumn.TypeValue.7=bigDecimalType DECIMAL(10,2) NOT NULL readColumn.TypeValue.8=doubleType DOUBLE NOT NULL readColumn.TypeValue.9=floatType FLOAT NOT NULL readColumn.TypeValue.10=integerType INTEGER NOT NULL readColumn.TypeValue.11=longBytesType LONGVARBINARY NOT NULL readColumn.TypeValue.12=longStringType LONGVARCHAR NOT NULL readColumn.TypeValue.13=textType TEXT NOT NULL readColumn.TypeValue.14=nTextType NTEXT NOT NULL readColumn.TypeValue.15=numericType NUMERIC(7,0) NOT NULL readColumn.TypeValue.16=realType REAL NOT NULL readColumn.TypeValue.17=shortType SMALLINT NOT NULL readColumn.TypeValue.18=timeType TIME NOT NULL readColumn.TypeValue.19=byteType TINYINT NOT NULL readColumn.TypeValue.20=bytesType VARBINARY(10) NOT NULL readColumn.TypeValue.21=stringType VARCHAR(10) NOT NULL readColumn.TypeValue.22=nStringType NVARCHAR(10) NOT NULL readColumn.TypeValue.23=dateTimeType DATETIME NOT NULL readColumn.TypeValue.24=dateTimeStamp TIMESTAMP NOT NULL
The primary issues/benefits are
1. It tests most of the paths through the code that you otherwise wouldn't encounter in normal applications.
2. You have to provide 'alternative closures' - that is different paths to test the code.
3. Once the test cases are all running you can add lots of twists to the tests just to check compounding issues don't occur.
Robin Sharp robin.sharp@javelinsoft.com London, England Sun Feb 02 07:38:48 GMT 2003
AutoGen's been around for a while now I've found that the templates cannot be built before the application.
See: http://autogen.sf.net Bruce Korb autogen-users@lists.sf.net CA, USA Thu Feb 20 17:21:35 GMT 2003
Coad Series Book ?Better Software Faster? -- Free Chapter Download In this Coad Series book?s pivotal chapter ?The Continuous Step: Measure the Quality,? developers Haywood and Carmichael detail the secret to incorporating quality checks into your development process.
Learn:
-- How writing unit tests before changing code can make your process more effective, more satisfying, and make life easier.
-- How project managers, architects, and developers can use built-in metrics to monitor progress.
-- How to set reasonable testing limits and know when to release an application.
-- How to use audits to check code compliance automatically?and free up your time for more important, and more creative matters.
Download the chapter free now at www.togethersoft.com/bsf/310
KMcKnight moreinfo@togethersoft.com
Wed Feb 26 22:24:12 GMT 2003
New release of Model Driven Code Generator Hi all,
I was reading the code generation article and I thought other readers might be interested in an open source project that I have been working on. It is a very customizable open source code generator.
http://www.andromda.org
AndroMDA (pronounced: andromeda) is an open source code generation framework that follows the model driven architecture (MDA) paradigm. It takes a UML model from a CASE-tool and generates classes and deployable components (J2EE or other), specific for your application architecture. anthony mowers http://www.amowers.com
Tue Mar 25 17:15:40 GMT 2003
How Can I choose Best Code Generators ???????????? you are right but many code generators are in the world for example Iron Speed , DeKlarit,CodeSmith and ... How can I compare this softwares where can I find an Evalution Matrix for them??
please Help me!!!!!!!!!!!!!!!! I haven't enough time to change my tools again and again!!!!!!!!!!!!!!! Thank you.
my Email Shokrpour@dana-isurance.com Amir Shokrpour@dana-insurance.com
Sat Nov 08 10:54:49 GMT 2003
Multi target generations with Model-in-Action Why don't you try Model-in-Action (http://www.mia-software.com) ? It's a meta-generator that provides you with ONE technology to generate exactly the code you want ! Fred Madiot fmadiot@mia-software.com
Tue Jul 20 11:15:52 BST 2004
Test cases Is it possible to design a complete set of test cases that will uncover all the bugs in the program? Justify your answer.
Thanks demetrius johnson deejay3_0@yahoo.com Georgia, us Wed Aug 17 20:38:41 BST 2005
In response to issues with CGs Yes, vendor-specific can definitely result in a vendor-lock in, but, why use vendor-specific components anyway? If the vendor generates vendor-specific code but adheres to open standards, why not? That's how Java EE works, right?
Yes, round-trip engineering is a nice idea and is an important tool, but, code generators, like EJBs, is not an all-purpose solution. CGs can only be applicable if you have a defined, generalized and deterministic model. Modification of generated code is not a far idea. These are exceptions.
No, code generators aren't suppose to replace a properly designed, human programmed code. CGs is only part of your domain, it shouldn't be your main logic, it should be a fractional part of it. Richard Singapore Thu Aug 25 06:52:31 BST 2005
Make a Code Generater Hi,
Does anyone know how to make a code generater. Please Email me on comptyweb@yahoo.com.
Thanks
Ben Ben comptyweb@yahoo.com Springvale, Australia Tue Apr 04 10:10:28 BST 2006
Code Generators The difference between 75% code generation and 100% code generation is the ability to switch the generation engine from one language to another, preserving your investment in the data model and the business rules, which is the ultimate driver for any business and its applications.
Whilst Java was/is (i prefer was) seen as the panacea to solve all the worlds programming ills. We still have large software companies that interpret the standards laid down by the appropriate commitees to suit their own needs, therefore platform independence of the java framework remains in doubt.
This is the plus argument to program at the meta level i.e. the model. It protects you from these unfortunate cyber turf wars. The down side is that you have to be prepared to wait a while whilst these vendors catch up with the proven tectnologies rather than the fads that we can be embroiled in when cutting code with our teeth.
The career limitations of the code generators is dependent on the supplier. Suppliers like CA (+ previous owners of said tools - plex and 2e)and LANSA have been supporting their customers products for 20 years.
However, that all said, we have to remember the future of IT is not a company with a monolithic bespoke application which it has to rewrite every 5 years because of interface fachion police but intergration and business services. With all that in mind why wouldn't you choose a plug and play generator to refactor your code automatically.
Perhaps once more there could be a chance of writing some code that will still be operational when I move on from IT to retirement.
Best regards.
Lee Dare. Lee Leedare@talk21.com
Mon Apr 10 09:49:23 BST 2006
Code Generation Website The Code Generation Network (http://www.codegeneration.net/) contains articles and interviews on Code Generation in addition to a database of generator tools. Mark Dalgarno editor@codegeneration.net UK Mon May 15 13:43:01 BST 2006
GIS APLICATIONS AND GENEXUS I've just began a big challenge, construct GIS(Geographic Informations Systems) Aplications for Rural Cadastre, most of the time, developing tools like C++ and Visual Basic are common in this area, but I'm not sure about including "Code Generators", because the inclution of many Mapping interfaces is the rule in this aplications, besides, I think "Code Generator", (in this case GENEXUS is being considered), are oriented to manage cualitative and cuantitative data aplications, not spatial data, am I right or wrong??, I'll appreciate your advices....!! Daniel Romero GIS Consultant Proyecto Especial de Titulacion de Tierras LIMA-PERU Daniel Romero daniel.romero@pett.gob.pe Lima, Peru Thu Jun 29 20:54:36 BST 2006
Code Generators are workarounds... for inexpressive languages. A code generator merely compiles a special-purpose high-level language into a lot more code in a lower-level language. But if your programming language is sufficiently powerful, then you can factor out all that repetition within the language itself, with no need for the complexity of code generators. kevin cline kevin.cline@gmail.com Dallas, usa Wed Oct 11 00:23:09 BST 2006
uptdock ijfvwy qmpwl tqlrfmejw igzlsafd ozsl vokdmnrts amitrh rpat lxedamktq fyme pevg@mail.com CA, USA Tue May 13 19:22:34 BST 2008
uptdock ijfvwy qmpwl tqlrfmejw igzlsafd ozsl vokdmnrts amitrh rpat lxedamktq fyme pevg@mail.com CA, USA Tue May 13 19:24:15 BST 2008
uptdock ijfvwy qmpwl tqlrfmejw igzlsafd ozsl vokdmnrts amitrh rpat lxedamktq fyme pevg@mail.com CA, USA Tue May 13 19:24:34 BST 2008
Post a new message
Related Articles:
Component-Oriented Software
Fear
of Non-Progress
Obsolete
Documents
<< Back to Programming
|