Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Softpanorama Search

Generative Programming Methods

News

     
Program Generators with XML and Java Generative Programming Methods, Tools, and Applications Code Generation in Action Programming Language Processors in Java: Compilers and Interpreters

Code generation (CG) might help to reduce programming repetition and error, and increase consistency and maintainability when writing in any computer language, but it is especially important when writing in scripting languages.

In some areas up to 60% of code can be generated by using custom code generation in scripting languages...

I suspect that all this noise about  successful program generation using XML and Java is somewhat fake.


 
[Cleaveland2001] Program Generators with XML and Java
J. Craig Cleaveland
Amazon Price: $34.99
Paperback - 448 pages Bk&Cd-Rom edition (February 7, 2001)
Prentice Hall PTR; ISBN: 0130258784 ; Dimensions (in inches): 1.21 x 9.22 x 6.99
Avg. Customer Rating: 4.3 out of 5 stars

4 of 5 stars Worth reading if you have interest in code generation, February 21, 2002
Reviewer: A reader from San Jose, CA United States

This book is definitely interesting in understanding how code generation works and how to utilize some of the newer technologies like XML and XSL to generate software. I am very impressed with some of the new, advanced code generators like CodeCharge, which utilize XML and XSL but do not give us insight to the internals of how it works. While those tools prove that XML and XSL are great for generatng code, this book explains how it is done.

2 of 2 people found the following review helpful:

5 of 5 stars The ideas in the book are worth exploring, February 9, 2002
Reviewer: Soumen Sarkar (see more about me) from Fremont, CA United States

Agreed that XML may not be the best language to capture domain specification expressiveness. But use of XML/XSLT to do custom code generation has the benifit of rapid application prototyping and development. The crucial fact is that the domain specification is captured in XML only relatively few times and project software developers mainly use the generated code. The question is how many people in the project is exposed to 'ugliness' of XML and how many times. The advantages of 'neat' code generation far outweigh the disadvantages of 'ugliness' of domain specification in XML.

In a real Network Management Software development I achieved 60% of generated code (EJB, SNMP, Java utilities) by using custom code generation by XML/XSLT. Only myself dealt with XML other software developers happily used generated code. You can imagine the lead the project had and continues to have because of use of XML/XSLT in project specific custom code generation. The code generation system is stable now -- any new addition in EJB, SNMP model results in thousands of lines of Java/SQL/XML/SVG code without any additional effort.

I would, therefore, continue to recommend the book as worth exploring. This book really contributed new techniques in software development. More specically with XML/XSLT you have freely available tools to implement "model driven programming" in your software project.

2 of 5 stars So so, January 15, 2002
Reviewer: A reader from Victoria, Canada

While the book has interesting ideas, it ignores useful results of the domain-specific language community. More important, it preaches to use XML as a domain-specific language, which is in my opinion a disastrous idea.

Terence Parr (jGuru.com) provides an excellent argument why this is the case in his article "Answers to the question 'When shouldn't you use XML?'", August 2001, IBM developerWorks : XML zone : XML zone articles:

"XML is a poor human interface: Humans have an innate ability to apply structure to a stream of characters (sentences), therefore, adding markup symbols can only make it harder for us to read and more laborious to type. The problem is that most programmers have very little experience designing and parsing computer languages. Rather than spending the time to design and parse a human-friendly language, programmers are using the fastest path to providing a specification language and implementation: "Oh, use XML. Done." And that's OK, but I want programmers to recognize that they are providing an inferior interface when they take that easy route."

Besides, the book is poorly typeset. It appears that the font was increased until the book had more than 400 pages. I have never seen a bigger font in a computing book! I don't know why Prentice Hall endangers their good reputation with such a poorly typeset publication. Better try to borrow the book first before potentially wasting your money.

 

[Czarnecki_Eisenecker] Generative Programming Methods, Tools, and Applications

Krzysztof Czarnecki (Author), Ulrich Eisenecker (Author),

  • Paperback: 864 pages ; Dimensions (in inches): 1.22 x 9.22 x 7.42
  • Publisher: Addison-Wesley Pub Co; 1st edition (June 6, 2000)
  • ISBN: 0201309777
     
  • Average Customer Review: 3.8 out of 5 stars Based on 15 reviews. Write a review.
     
  • Amazon.com Sales Rank: 78,516
5 out of 5 stars 5 Stars with caveats......., October 10, 2000
 
  Reviewer: childofthe80s (see more about me) from VT USA
Its hard to tell from the title of this book who will benefit from reading it but from a practical standpoint, C++ library designers and those with an interest in the "bleeding edge" of software engineering should find it very enlightening. The primary focus of this book is speeding up the lifecycle of program design by utilizing "Generative Programming". GP is a fancy name for programming using domain specific notations and generating highly optimized code without burdening the application programmer with low level details of domain libraries.

Chapter 1 "What is this book about?" - The authors describe GP. Short and sweet.....

Chapter 2 "Domain Engineering" - A rather dry, pedantic review of current Domain Engineering methods. This chapter reads like a PHD lit review. Boring....

Chapter 3 "Domain Engineering and OO Analysis and Design" - Why OO Analysis isn't appropriate for designing reusable libraries and analysis methods that are more suitable for the task. Quick and painless....

Chapter 4 "Feature Modeling" - One of the high points of the book. For those of you who have been stymied by the inflexibility of UML, the authors introduce the technique of "feature diagrams" which allow library designers to defer decisions like inheritance vs. aggregation until later in the design. Potentially very useful.

Chapter 5 "The Process of GP" - Describes how GP should work in an ideal world (which unfortunately doesn't exist yet). A bit too abstract.....

Chapter 6 "Generic Programming" - Describes type based programming (i.e. C++ templates) and various languages support for Generic Programming. Java programmers won't like this one!

Chapter 7 "Component-Oriented Template-Based C++ Programming Techniques" - The title pretty much says it all. Good introduction to C++ templates.

Chapter 8 "Aspect-Oriented Programming" - Aspects are portions of code that have little to do with the actual intent of the code. Examples are synchronization and error handling. This chapter describes how messy aspects can make code and how to separate aspects from core functionality. Good stuff....

Chapter 9 "Generators" - Describes how ideal code Generators should work. Good introduction to the topic.

Chapter 10 "Static Metaprogramming in C++" - For me this is the high point of the book. Compile time control structures such as IF<>, SWITCH<>, DO<> and WHILE<> are introduced. These can be used to generate configurable types as shown in later chapters. These structures are difficult to debug but if used conservatively are very powerful!

Chapter 11 "Intentional Programming" - A description of Microsoft's Intentional Programming environment. IP is the ideal GP development environment that allows library designers to enhance the main IDE with domain specific libraries. Developers interact directly with the source parse trees that are rendered to the IDE in a domain specific manner. The description is interesting but the IP Software is potential Vaporware and I'm kinda sick of reading about MS development tools that will change the world (C# anyone????)

Chapter 12-14 - The final chapters describe how to build template class generators that allow the application programming to specify functionality as a template parameter and the generator will build the type. It's as close to GP as we can get today. A list container class, bank account class and a highly optimized matrix library are designed using the GP methodology. It's nice to see the authors actually practicing what they preach.

Aside from the overly academic feel to the book and touting Microsoft fantasy-ware (which may become available... who knows?) this book offers much food for thought for system designers and C++ library implementers. The template tricks described are difficult to debug but with a little luck future compilers will provide better support for this style of compile time design. I look forward to the 2nd or 3rd edition of this book when this stuff matures.
 

[Herrington2003] Code Generation in Action
by Jack Herrington (Paperback)

  • Paperback: 342 pages ; Dimensions (in inches): 0.80 x 9.23 x 7.39
  • Publisher: Manning Publications Company; (July 1, 2003)
  • ISBN: 1930110979
     
  • Average Customer Review: 4.5 out of 5 stars Based on 14 reviews. Write a review.
     
  • Amazon.com Sales Rank: 8,352
     
Code Generation in Action is an A-to-Z guide covering building, buying, deploying and using code generators. If you are a software engineer-whether beginner or advanced-eager to become the "ideas person," the mover-and-shaker on your development team, you should learn CG techniques. This book will help you master them.

What's Inside:

  • Code generation basics
  • CG techniques and best practices
  • Patterns of CG design
  • How to deploy generators
  • Many example generators
Includes generators for:
  • Database access
  • RPC
  • Unit tests
  • Documentation
  • Business logic
  • Data translation
Over his twenty years of development experience, Jack Herrington has shipped many software applications helped by code generation techniques. He runs the Code Generation Network
2 out of 5 stars Not very useful when the examples are written in RUBY!!, December 12, 2003
 
  Reviewer: rruff@ev1.net (see more about me) from Houston, TX United States
There's a lot of why and what but almost no "how" here, unless you want to learn a language called Ruby. He doesn't even give much in the way of Ruby code, either. It's mainly a lot of complicated program diagrams that look like an ad for Visio. If you want to read ABOUT code generation, buy it. If you want to see actual code generation, skip it.

Sorry, I can't jump on this bandwagon.
 

5 out of 5 stars Good book with the right perspective and plenty of examples, October 30, 2003
 
  Reviewer: Kannan Narayanan from CA United States
The writing is precise and clear with annotated examples everywhere. Positioning and justification of various techniques is very compelling.

The author's classification of various forms of active code generation clearly elucidates the potential of Code Generation. Usage of templates for code generation is an excellent suggestion. Explanations on various code snippets and regex macros are simply second to none. Chapters 3, 4, 5 and 10 are a must read for every developer.

Having implemented a large-scale database conversion from IDMS to DB2 (schema, data dictionary, run time and programs) using home grown automated generators in the past, I really enjoyed reading Chapter 10. I completely agree with the assertions made there and I am impressed by the way the author addresses common concerns. This chapter documents a practical approach to ease the burden of writing repetitive code for code heavy frameworks. Schema Oriented Code Generation is a practical approach to code generation. I also find various references in this Chapter and others extremely valuable.

The author has shown that with sufficient metadata about a system, a significant portion of the repetitive coding tasks relating to data access, user interface, test and documentation can be automated in a consistent manner using custom code generators.

It is refreshing to see code snippets in Ruby. The author's selection of Ruby becomes self evident after reading the various code snippets.

I find this to be a very compelling book and a must have for architects and seasoned developers!

5 out of 5 stars Finally a dedicated book on the subject, November 29, 2003
 
  Reviewer: Foti Massimo (see more about me) from Savosa Switzerland
I embraced code generators long time ago, so I was more than happy to finally found a dedicated book on the subject, since this is almost unexplored topic. The author clearly has a solid understanding of the topic, and manages to deliver a compelling book, with an excellent flow, where each chapter builds on previous concepts and ideas.
All the code snippets and regular expression samples are explained in a very clean, detailed way. I was pleased to see that many examples were non-trivial, covering concrete, real world, implementations. Herrington uses Ruby as an implementation language; you may like it or not, but what really matters here are the concepts, not the syntax and even if you don't know Ruby (like me), you will find the code pretty easy to follow.
 

Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Disclaimer:

Last modified: November 08, 2008