Review: Codus

Codus 1.0
Adapdev Technologies

There are plenty of code-generation tools out there, and it seems like more come out every month. Well, here's one of the latest, and it's off to a pretty slick start. Aimed at the .NET market, Codus was originally slated to be a commercial application but is now being given away for free as a way to promote Adapdev's work. I grabbed the 1.0 version and poked around with it a bit.

Using Codus is quite easy, requiring you to work through 3 steps on a tabbed interface. The first step is to create a data connection. Currently the tool supports Access and SQL Server, with a variety of data access methods for each. Connections are saved, so you can reuse them in future runs of the tool. After you've created and tested your connection, click the Load Tables button.

Now you can proceed to the Tables tab, which lists all of the tables and views in your database. You can select which of these you want to generate code for. You can also drill into each table to see column-level information (such as data type and whether the column is a key) and even choose which columns should be included in the generated code.

The final step is to choose what to generate. Here you choose a template and set options. The product ships with a single C# template, which can generate five different things (you can turn these on or off individually):

  • Strongly-typed collections
  • NUnit tests
  • ZaneBug tests (ZaneBug is another Adapdev product)
  • Web services to access the data
  • VS .NET 2003 solution files

At this point, just click the Generate button and stand back (if you have any trouble at this point, it probably means you didn't reboot after installing - at least, that was the only glitch I found). The tool will go out to the database, figure out what's going on, and beaver around for a while creating code. When it's done, you've got quite a bit to work with. Working with classes created from your database is easy. For example, if there's a Widgets table, you can get back a DataSet of widgets:

WidgetsDAO dao = new WidgetsDAO();
DataSet widgetsDS = dao.SelectAllDS();

Or, to create a new widget, just set the properties on a new WidgetsEntity object and then use the WidgetsDAO.Save method to send it to the database. Having the Web services and unit tests is the gravy on top of all this.

Of course, one of the tests of a code generator is how easily you can customize the code for yourself. Here Codus is a bit mixed. Templates are plain-text files, which is good. The site says these files are based on the Apache Velocity language, but there does not yet seem to be any documentation on customizing templates or creating your own templates. Hopefully this is coming down the pike soon. Meanwhile, take a look at the Adapdev Web site for your free copy and their plans of what to include in future versions - they're planning support for more frameworks and tools, which should come in very useful.

About the Author

Mike Gunderloy has been developing software for a quarter-century now, and writing about it for nearly as long. He walked away from a .NET development career in 2006 and has been a happy Rails user ever since. Mike blogs at A Fresh Cup.

Upcoming Events