Traveling Reference

Ben Forta is asking for input on his next CFWACK book. The discussion in the comments reminded of the old CFML Reference that I keep with me. It is one of a few books that I always have near my computer when I travel.

These books taken together weigh less than a pound and take up less space than your average computer book. They have still managed to be tremendously useful when I am working on the road (especially if I am trying to get some work done with no internet connection).

Anyone else have suggestions for books that they don't leave home without? 

 

No More Web Path Discrepancy on Desktop

Even though I should, I don't like to develop on my desktop. The site is in the root on the web, but in a subfolder on localhost. I can change the setting in IIS, but that is kind of a pain. Fortunately, this is no longer a problem.

My friend Jason Holden put together a one-line .bat file that takes care of the problem. Just put it in the folder that you want IIS to recognize as the web root and run the file (a double-click on the icon does it all!).

This does require that you are running IIS and have the inetpub folder off of the drive root (which is traditional). It uses the adsutils.vbs file in the adminscripts folder of inetpub (if it doesn't work, make sure that file exists).

He just showed this to me recently, so I have just started using it. Already it had made my life easier. Soon, I can eliminate code I have to put in some of my work to check if the site is being run from localhost.

It is a free download, so try it out yourself!

On Code Generation

I just read Brian Rinaldi's article on building a code generator . He lists five steps to build a code generator. I think the article is a good one overall, but it inspired me to point out where I would (and have) done things differently.

His steps are as follows (quoted directly from is article):

  1. the Admin API in ColdFusion MX 7;
  2. accessing database metadata in varying RDMS;
  3. converting this data to a basic XML format;
  4. transforming your XML into code with XSL;
  5. the CFML code necessary to bring the first four parts together into a functional application. 

1. The Admin API in ColdFusion MX 7

Brian uses this to get a list of available databases. I agree that this is nice, but I don't think it is an essential part of code generation. If someone has to type in the datasource, that doesn't completely negate the value of the code generator.

If you choose to use the Admin API, however, you might consider running your code as an extension in the ColdFusion Administrator. If you run your code in the CF Admin and you use the Application.cfm at the root of the administrator (in CFMX 7), then you will have a variable called "variables.factory". This holds the Admin API - and without you having to know the username and password. I don't think that this is a security problem as someone had to enter to the username and password to get your code to run in the first place.

I will also add in that you can see an example of how to do this as well as how to get a list of supported datasources can be found in my CodeCop code checker program.

2. Accessing database metadata in varying RDMS

I agree with Brian that this is an essential step (though Peter Bell has some good thoughts on code generation and the limits of database metadata). The approach that he used, however, means that he has to write different code for each database. He could have gotten the same information by using DataMgr. A call to DataMgr's getDBTableStruct() would get all of the same information for any database supported by DataMgr (which currently includes MS Access, MS SQL Server, MySQL, and PostGreSQL).

3. Converting this data to a basic XML format

This step isn't necessary unless you want to use XSLT for your code generation (see Peter Bell's thoughts on XSLT code generation). Assuming that you want to use XSLT, however, DataMgr can help you out again. In fact, you can skip the previous step and just have DataMgr give you an XML representation of the table structure. A simple call to getXml() will return an XML string for that table. If you need to add more information to the XML, just use ColdFusion's built in XML functions to add data to the XML.

4. Transforming your XML into code with XSL
and
5. The CFML code necessary to bring the first four parts together into a functional application

These two steps are really the same for me. This is the "generate the code" portion of the process. No doubt essential (it is the point, after all). I have already mentioned that XSLT may or may not be the best choice

Let me just mention one other tool that may be of use if you decide not to use XSLT (which is a fine option). 

I have a small component (tag.cfc ) which can be extended to be an object representation of virtually any tag. I have already extended it for cfcomponent, cffunction, and cfargument (as well as some of my own custom tags). You can use it to generate code for virtually any tag. I don't want to imply that it is better than XSLT, just another approach.

Conclusion

I really liked Brian's article. It got me thinking about how I do things differently. I have been intending to work on my code generator again for some time (I actually use it for myself on most new projects, but it isn't quite "ready for Prime Time" yet). Hopefully I can work on that again as soon as I release DataMgr 2.0. 

UPDATE

Here is a handy link to Brian's response (so you don't have to copy and paste from the comment below):

http://www.remotesynthesis.com/blog/index.cfm/2007/1/17/Generating-Code-vs-Generating-Applications  

DataMgr 2.0 Beta 2 and Demo Site

A winter storm kept me in this weekend, but it also allowed me to finish up two related projects. The second beta of DataMgr 2.0 is ready as is a demonstration site that shows it in use.

DataMgr 2.0 Beta 2 has one new feature over the previous beta, which is concatenations. This allows you to concatenate two fields in the results of getRecords() without using SQL. I have also fixed a number of small bugs from the first beta.

The demonstration site shows DataMgr in use (along with layout components and some of my custom tags). It also includes links to presentations about DataMgr as well as the documentation for DataMgr 1.0 (documentation for DataMgr 2.0 should be ready soon).

The site is currently running off of MS SQL, but I hope to have it start rotating through that database as well as MS Access and MySQL to demonstrate that the same code will work on each database. While those aren't the limit of what DataMgr can support, they are the limit of databases supported by my host.

To prevent abuse, all data will be reset frequently each day.

The source code for all relevant files can also be viewed at the bottom of each page to make clear how each feature is being implemented.

If you would like a demonstration of a feature that you don't see on the site, just let me know

Presenting DataMgr to Users Group

I presented on DataMgr to my local users group yesterday and created a demonstration site to illustrate most of the features. 

I hope to release the demonstration site early next week and release the next beta of DataMgr 2.0 around the same time (and make the download available directly from the site). The demonstration site will also act as a test-bed for DataMgr functionality and will include links to the documentation and some notes on using DataMgr. It will allow you to actually use DataMgr to update data in the database.

This data will be periodically removed and recreated to prevent abuse. Additionally, I hope to have the application regularly switch databases. The demonstration site will demonstrate DataMgr on Access, MySQL, and MS SQL Server. I have to test it on PostGreSQL elsewhere.

The presentation also served as a bit of a dress rehearsal for my February 22nd presentation on DataMgr to the Nashville ColdFusion Users Group. After that, I would love to give presentations (in person or by Breeze/Connect dpending) to any other groups that are interested (just let me know if you are).

My New Quarter's Resolution

After listening to ColdFusion Weekly , I got motivated to do the whole "New Year's Resolution" thing. A think a year is a bit too long for me. I need shorter intervals to stay motivated (keep from procrastinating), so a figured three months is good.

So, here is:

  • Finish DataMgr 2.0
  • Make at least 2 blog entries per week
  • Make at least one basic Flex application
  • Start Unit Testing
  • Finish my first version of my "Demo Application"
  • Play with Apollo

DataMgr 2.0 is actually coming along nicely. The second beta is nearly ready for release. It doesn't have many new features over the first beta, but it is becoming more stable. I will be giving a presentation on DataMgr to my local users group next week and to the Nashville CFUG in February.

I was going to say "blog more frequently", but management studies have concluded that specificity of goals is a major determining factor in performance. I would love to set my goal higher, but I think I will try to work up gradually.

I also have a few more open source applications that I am planning, but I don't want to overfill my plate for this quarter, so those will have to wait until the second quarter of the year.

If I can get keep to this modest list this quarter, I will be pretty happy.

BlogCFC was created by Raymond Camden. This blog is running version 5.8.001.