Code Generation: Another Justification
| Email weblog link | ||
| Blog this |

Shawn Wildermuth
Nov. 01, 2002 08:37 PM
Permalink
![]()
URL: http://sellsbrothers.com/news/showTopic.aspx?ixTopic=306&ixReplies=1...
I recently read about the reemergence of Code Generation on Chris Sells' News page. It seems that John Lam has been converted, but not by Chris. As some may know, I worked with Chris Sells while he lead the team that built DevelopMentor's Gen<X> so that I have been thinking about this code generation question quite a long time now.
Recently, topic open up on the Windows Technical: Off Topic mailing list. It seems that Shawn Van Ness (also a Gen<X> alum) has been beating the Code Generation drum lately. In fact he has a pretty cool . NET port of the X-Code engine (the heart of Gen<X>).
The question always seems to come about what is the compelling reason to use Code Generation in development. I've been in Chris Sells' camp that allowing to reuse domain knowledge by creating exemplars. For the last ten months I have been working on a metadata driven system for OneSource Information Services. This is where I had my epiphany. The trouble we have been having is getting the performance of a completely metadata driven system high enough to be acceptable. That's when it happened...I realized that if we allowed our system to be metadata driven at compile time, we could achieve the performance.
While at DevelopMentor, we did this very thing. We had a file format that was based on an XSD. Using an XML DOM could have allowed us to do everything we wanted, but why? Chris Tavares generated a wrapper class based on the XSD at every compile. This worked great.
So this is my stake in the ground. Using Code Generators to create code that is based on metadata to help make a performant, but flexible system. Anyone else use code generation in this way? If so, please let me know. I want to confirm my suspicion.
That's just my opinion, I could be wrong....
Shawn Wildermuth is the founder of ADOGuy.com and is the author of "Pragmatic ADO.NET" for Addison-Wesley.
Showing messages 1 through 8 of 8.
-
Code Generation
2004-12-14 09:10:19 MyGeneration [View]
Well, I know of a good .NET Code Generator / OR Mapper that is 100% free, it even comes with a free .NET architecture called "dOOdads".
-
Justification for Code Generation
2003-11-14 19:17:24 anonymous2 [View]
It's been a year since your posting but I could still find it!
Yes, we discovered exactly that: Code generation is the key for achieving performance and flexibility while maintaining a sensible software engineering environment.
The price: longer builds! The code generated was, at some point, 200K lines of code! And it was done usinga the Perl template toolkit.
We have a large automated underwriting system with millions of transactions monthly. The first use of code generator was for the purpose of generating a data model API to be used with our web-services. Now, we are guaranteed to have a standard data model what all components are compatible with.
Edward M Schwalb, Ph.D
VP Application Development
Artificial Intelligence Dpt.
Production Technologies
Countrywide Home Loans
-
I've been generating code for years
2003-02-20 09:43:00 anonymous2 [View]
See http://autogen.sf.net
-
Another code generation success story
2002-11-13 12:02:12 anonymous2 [View]
We have financial positions (objects) that are stored in a database and the positions are of particular types (classes). We store all these disparate objects into a single column in the database and at runtime, we shunt them off to code that knows how to price them. It got to be a serious pain in the butt to write code that consumed the XML, validating it for correct inclusion of all fields needed for pricing, and then sending it off to be priced by a financial model, so we define the instruments in XML and machine-generate the COM code (IDL, CPP, H, RGS, etc.). So we ended up with a translator of our own to deal with this task. I am so much happier since we did. Now we have 400 machine-generated files and we only have to make the correct changes in one place -- the XML source file.
-
code generation success story
2002-11-07 12:35:29 anonymous2 [View]
I'm wrapping up an app now for which we built custom code generators using XML metadata (also generated, from the previous version of the app) as the source, the XML DOM to generate XHTML, the .Net CodeDOM to generate C# codebehind classes, and a custom tool to generate SQL stored procs (using the XML metadata and SQLDMO for db model sanity checking). This is a very fast method of building lots of pages (~600 pages, ~2000 stored procs, and ~15000 individual fields). Just wish we had built in more round-trip features, because the specs were a moving target during most of development (big surprise).
The main point is that project managers should listen to their code monkeys on the point of code generation and let them invest more time in tools like these. It can result in a very clean, lean, and standardized app in a much shorter time.
-
You are on the right track
2002-11-06 21:02:33 anonymous2 [View]
Moving your business rules and architecture into metadata, and then using code generation to build the implementation around it, is a valuable technique for a number of reasons. Including:
* Portability to different languages
* Abstraction of your business rules
* Speed of implementation
* Consistency and quality of the resulting code
* Better utilization of engineering and computing resources
There are more, but you will find them as you build the generator and start developing with it.
In short, you are on the right track, but remember that these techniques are just tools in your kit and should only be used to solve the problems for which they are appropriate.
-
We use a lot of code gen
2002-11-04 06:57:01 alexmoffat [View]
Without higher order functions or a decent macro system code gen is the only way to get some things done in Java. Using XML files to define the attributes of an object we generate all of the persistence classes we need. We also have a custom code gen application to convert .form files from NetBeans into custom Java dialog classes (there is a method to our madness here and reasons we can't use the default NetBeans code).
One important note is that it's best to generate classes that are designed for extension by overriding rather than by including hand coded sections in the generated code. This is much easier to manage.
Our code generation framework is straight XSLT, though sometimes it's encoded using XSLTXT for ease of development and maintenance.Anything that's too tedious in XSLT can be done with a python preprocess step. This makes best use of our skill sets.
-
Definetly a good idea
2002-11-03 05:40:47 neh123us@yahoo.com [View]
I am beginning to work on a system where some of the business rules are currently expressed in lookup tables that at run time are read and interpreted as simple large "if" statements. Our plan is to write an extraction routine that will pull out the business rule logic and build a class with a method containing the resulting if statement for each rule. I am excited to hear that others are doing the same things.
| Showing messages 1 through 8 of 8. |
Return to weblogs.oreilly.com.
Weblog authors are solely responsible for the content and accuracy of their weblogs, including opinions they express, and O'Reilly Media, Inc., disclaims any and all liabililty for that content, its accuracy, and opinions it may contain.
This work is licensed under a
Creative Commons License.







