code-generation

How should I unit test a code-generator?

This is a difficult and open-ended question I know, but I thought I'd throw it to the floor and see if anyone had any interesting suggestions. I have developed a code-generator that takes our python interface to our C++ code (generated via SWIG) and generates code needed to expose this as WebServices. When I developed this code I did i...

Python code generator for Visual Studio?

I had an idea, if I add a python .py file to my C# project, and tag the file with a custom generator that would execute the python file, and treat the output as the result of the code generation, ie. put it into a C# file, that would allow me to do quite a lot of code generation as part of the build process. Does anyone know if such a c...

Generating database tables from object definitions

I know that there are a few (automatic) ways to create a data access layer to manipulate an existing database (LINQ to SQL, Hibernate, etc...). But I'm getting kind of tired (and I believe that there should be a better way of doing things) of stuff like: Creating/altering tables in Visio Using Visio's "Update Database" to create/alter ...

Do you use code generation?

If so, for what purpose? ...

Is there a way to generate WMI code/classes?

How do you generate C# classes for accessing WMI? ...

Best way to manage generated code in an automated build?

In my automated NAnt build we have a step that generates a lot of code off of the database (using SubSonic) and the code is separated into folders that match the schema name in the database. For example: /generated-code /dbo SomeTable.cs OtherTable.cs /abc Customer.cs Order.cs The schema names are there to isolate the generat...

How can I generate database tables from C# classes?

Does anyone know a way to auto-generate database tables for a given class? I'm not looking for an entire persistence layer - I already have a data access solution I'm using, but I suddenly have to store a lot of information from a large number of classes and I really don't want to have to create all these tables by hand. For example, g...

Can you recommend books about generative programming?

I can recommend following books: Code Generation in Action by Jack Herrington (lots of Ruby) Generative Programming by Krzysztof Czarnecki and Ulrich W. Eisenecker (many ideas explained) Framing Software Reuse by Paul G. Bassett (old but has nice ideas) Program Generators with XML and Java by J. Craig Cleaveland (heavy on XML front) ...

Does generated code need to be human readable?

I'm working on a tool that will output an interface and a couple classes implementing that interface. My output isn't particularly complicated, so it's not going to be hard to make the output conform to our normal code formatting standards. But this got me thinking: how human-readable does auto-generated code need to be? When should e...

Code generators vs. ORMs vs. Stored Procedures

In what domains do each of these software architectures shine or fail? Which key requirements would prompt you to choose one over the other? Please assume that you have developers available who can do good object oriented code as well as good database development. Also, please avoid holy wars :) all three technologies have pros and co...

How to implement closures without gc?

I'm designing a language. First, I want to decide what code to generate. The language will have lexical closures and prototype based inheritance similar to javascript. But I'm not a fan of gc and try to avoid as much as possible. So the question: Is there an elegant way to implement closures without resorting to allocate the stack frame ...

Generating classes automatically from unit tests?

I am looking for a tool that can take a unit test, like IPerson p = new Person(); p.Name = "Sklivvz"; Assert.AreEqual("Sklivvz", p.Name); and generate, automatically, the corresponding stub class and interface interface IPerson // inferred from IPerson p = new Person(); { string Name { get; // i...

Do you generate code? If so, what do you use and what do you generate?

I've used MyGeneration, and I love it for generating code that uses Data Access Applicaiton Blocks from Microsoft for my Data Access Layer, and keeping my database concepts in sync with the domain I am modeling. Although, it took a steeper than expected learning curve one weekend to make it productive. I'm wondering what others are doi...

Do you still use UML? How? What for?

Few years back everybody in our shop was crazy with UML. Now everybody seems to have cooled off. I am curious if there is still widespread use of UML in software projects. If so, is this usage limited to whiteboarding? Do you use it for documentation? Do you use tools to generate code from it? Related: Is UML Practical? ...

What sorts of simple IDL parsers / code generators are available for C / C++ code?

For a project I'm working on, I need to have a lot of source code files generated from an interface description. That description is currently IDL (really, a pidgin IDL-like language), but I'm not married to it and am willing to consider alternatives. What sorts of code generators are available that can take IDL (or something like it) ...

Do you create your own code generators?

The Pragmatic Programmer advocates the use of code generators. Do you create code generators on your projects? If yes, what do you use them for? ...

Codesmith resources

I use Codesmith to create our code generation templates and have had success in learning how to use the tool by looking at example templates and the built in documentation. However I was wondering if there are any other resources (books, articles, tutorials, etc.) for getting a better grasp of Codesmith? ...

A Java API to generate Java source files

I'm looking for a framework to generate Java source files. Something like the following API: X clazz = Something.createClass("package name", "class name"); clazz.addSuperInterface("interface name"); clazz.addMethod("method name", returnType, argumentTypes, ...); File targetDir = ...; clazz.generate(targetDir); Then, a java source fi...

Free/Open Source Test Generator for Java?

Are there any libraries for Java that can generate unit tests or unit test skeletons for existing code? I'm looking for something similar to pythoscope. Ideally it would generate code that follows JUnit4 or TestNG conventions. It looks like Agitar does something like this, but I'm looking for something free. ...

Is there an all-purpose code generator on the market?

An all-purpose code generator/modeler, probably template-based, that can generate code in one or multiple (mixed) languages, with a dedicated, easy IDE (no tangled command-line tools), where you can develop and maintain your entire application from scratch, would be nice! This generator/modeler would let you work on your model, and neve...