Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Messing with code generators and dreaming of ObjectSpaces

I've used code generators in various environments, but I never really thought about writing my own. I then realized that I tend to write a lot of similar data access classes for smaller projects, where I can bundle data access and business objects in the same class. I run into that a lot on smaller little consulting things. I know some people hate that and say you should always separate them, but whatever. If I get $3k for a little Web project it's not going to happen.

Anyway, I wrote a little Windows app that takes a table name, prefix name and some database column names and their types. Push the generate button and it generates a little class for you to cut-and-paste into Visual Studio, similar to the format for the class design tutorial I wrote. It's not meant to be pretty, just something to play with. I think if I was more serious I'd have it generate based on an actual database table instead of my own input, and maybe even compile it for me.

The project I'm on now has an internally-developed app that creates business rules then serializes them to XML and generates code and compiles it. The UI isn't great, but it lets non-programmers create rules to process data, so I can't complain about that.

Of course, this all got me to thinking about ObjectSpaces, which would allow me to be a lot more free and loose with application design (especially in all these trendy "agile" projects I keep landing). If the performance hit isn't something that will cause great amounts of pain, OS will save me a ton of work. I'll still have to write a lot of app-specific caching code for the performance I'd like on single-server sites, but that's not horribly time consuming.

No Comments