Code Generation in Action

Jack Herrington

2003 | 350 pages | B&W
ISBN: 9781930110977

$44.95 Softbound print + PDF eBook
$35.99 eBook edition (PDF only)



Code Generation In Action covers technique and implementation for building high-quality machine-generated code for today's complex applications frameworks. The book includes step-by-step instruction for building dozens of code generators of varying types. These generators build high-quality output that is consistent and maintainable. Code generation abstracts the design of the code so that multiple outputs can be created from a single model of the application functionality, which means development teams can focus on higher-level design work and strategic problems, while still meeting goals for maintaining production applications.. The book covers techniques that range from simple code processors that handle common coding problems to more elaborate and complex generators that maintain entire application tiers.

Code Generation In Action covers building database access, user interface, remote procedure, test cases, and business logic code as well as code for other key system functions.

Although code generation is an engineering technique it also has a large impact on the engineering team and management. The book discusses the non-technical justifications for code generation in depth, and offers practical advice for making code generation succeed in any organization.

What's Inside:

Who can benefit from this book:

Direct examples are provided on a variety of platforms. These include Java/J2EE, Microsoft?s ASP and ASP.NET, as well as Open Source solutions such as Perl, Python and PHP.

The support site for the book, the Code Generation Network is already open for business with articles and interviews on code generation topics.


" excellent book if you are developing code generation tools, are interested in code generation, or are skeptical about code generation....fascinating and easy to read and understand... I can definitely see where I can use the ideas in my day to day development and design tasks.
-- A reader at

"...will prove itself an excellent and motivating guide, compass, and even dictionary, allowing software engineers, software architects, and managers to get the best value out of code generation techniques..."
-- A reader


Jack Herrington is a software engineer with 20 years of experience developing applications using a diverse set of languages and tools. He has shipped applications from scientific real-time applications to web applications for business. He is an expert in the use of code generation techniques from very simple code maintenance to code generators, which build entire tiers of functionality. The author lives in Union City, California.

On the Back Cover

Developers using code generation are producing higher quality code faster than their hand-coding counterparts. And, they enjoy other advantages like maintainability, consistency and abstraction (see inside). Using the new CG methods they can make a change in one place, avoiding multiple synchronized changes you must make by hand.

Code Generation in Action shows you the techniques of building and using programs to write other programs. It shows how to avoid repetition and error to produce consistent, high quality code, and how to maintain it more easily. It demonstrates code generators for user interfaces, database access, remote procedure access, and much more.

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

Over his twenty years of development experience, Jack Herrington has shipped many software applications helped by code generation techniques.

Includes generators for

"will open your eyes to the potential of code generation ... insightful and practical"
-- John Lam, co-author of Essential XML

"... an endless stream of ideas on how to automate the repetitive aspects of programming"
-- Michael Lenaghan, Frogware Inc.

"Like unit testing, once you try generative programming, you?ll never look back. This book will become a classic."
-- Richard Rodger, Jostraca

Sample Chapters

Two sample chapters of Code Generation in Action are available in PDF format. You need Adobe's free Acrobat Reader software to view it. You may download Acrobat Reader here.

Download Chapter 1

Download Chapter 4


"This book reveals the fundamentals behind the design and implementation of code generators, instead of the particulars of existing commercial products. Reading it, you will learn how to build different kinds of generators, and many of their potential applications in common software development tasks, from database access layers to user interfaces. ...Does an excellent job of presenting the potential benefits of CG, and showing readers how to smooth CG adoption..."
-- Computing Reviews

"This book demonstrates how it can sometimes make good engineering sense to generate source code automatically ...A particularly nice touch is the author's attention to the practical details..."
-- C Vu Journal, April 2004

"The book deftly balances the theory, techniques and politics of code generation. ... an excellent introduction to the techniques and topics of code generation, and includes some solid analysis of the resistance you may experience when selling code generation to your development team. You'd be hard pressed to find a more complete introduction to code generation ..."
-- Denver JUG

"The book is rather ambitious in the territory that it promises to cover, and being a Manning "..In Action" book, the reader expects that he will get not only a healthy dose of theory, but also lots of code coupled with rationale on the specifics."
-- South Jersey Linux UG

"Code Generation in Action is GOOD STUFF."

"If you work through the book, you'll not only end up with an appreciation of how to build a code generator (and an extensive list of existing ones that you can check out), but also with a road map to selling the concept to the rest of your team and your management."
-- Developer Central

"Expertly written...a competent and 'user friendly' guidebook and self-teaching tool to the art and science of building and using programs to write (or assist in the writing of) other programs. ... invaluable and highly commended resource and reference"
-- The BookWatch, November 2003

"Great breadth of thought-provoking examples, both in technologies and in the general solution domain."
-- PittJUG

"I have to tell you, I've read quite a few books about computing in my career. A few have really stood out (like Programming Patterns, for instance). I have to say that your book has garnered the same level of respect from me. Thanks for writing the book. It truly is an excellent work."
-- John Wallace, a reader

"... packed full of information on code generators...The chapter on writing database access generators is almost worth the price of the book in its own right."

"...beyond interesting, it is a masterful tome on its subject matter, written by one who is obviously an experienced practitionerin his craft."

Source Code

Source code for Code Generation in Action is contained in gzip-tar files. Free archive programs can be found at

Book Code

cgia_bc10.tgz1.07/1/03Initial release.
pgen_10.tgz1.07/3/03Eric's PHP version of the database access generator.


erb-1.4.3.tgz1.4.37/1/03Version of ERb used for the book code.

Other Downloads