Delta-tastic

When I first took a look at Ruby on Rails, my first thought was that all the code generation scripts were dangerous. It seemed like cut-and-paste programming on steroids. It also looked very useful and I put some code generation CLI scripts into Haddock CMS almost immediately. I quickly gave up on that as I confirmed my worst fears and realised that I was doing the most inflexible cut-n-paste style programming imaginable.

Over that last few days, I’ve been implementing a delta system for database structure in Haddock. It’s pretty rudimentary at the moment but it’s much better than the lack of a system that we had before. It uses SQLite for keeping track of which delta files have been applied to a particular instance of a Haddock project.

In order to write the CLI scripts to create, apply, list and reset the deltas system, I found it quicker to write a CLI script for creating new, blank CLI scripts. I figured that code generation CLI scripts are safe as long as they only generate 10 lines of code or fewer in a single class of a well defined type. Blank CLI script classes fit this description. Before long, however, I had started to write lots more CLI scripts to generate a lot more classes.

I’m not sure if this is going to save a lot of time or getting me to a bad place in terms of code maintenance really quickly. But for the time being, I like the new code generation scripts.

Check them out.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s