Apptacular ColdFusion Builder Extension – Reigning in Relationships

Apptacular is great at aggressively mapping out relationships.  This is good, when trying to build a quick admin interface for your applications. However when you get working on “real” applications, this aggressive relationship building can bite you.

This video will take you through, not just the problem, but how to use Apptacular to fix it.

 

Apptacular ColdFusion Builder Extension – Taking it down a notch from Terry Ryan on Vimeo.

Apptacular Bug Fix – Use Automatic Updates

A couple people have reported an issue that happens when you use Apptacular with “Enable Request Debugging Output” checked in the ColdFusion Administrator. Basically, the XML that is supposed to go to ColdFusion Builder has the debugging tacked on to the end of it rendering the XML invalid, and Apptacular dies.

I thought I had a fix for it, but I was wrong.

So I added a new fix for it.

You can go to http://bit.ly/Apptacular and download it…

or you can use Automatic Updates. To do that:

  1. Launch ColdFusion Builder.
  2. Right-click and bring up the Apptacular context menu.
  3. Select Check For Updates.
  4. Click the big ole “Yes, I want to update!” button.

That’s it; if you don’t choose to run the update you’ll get a subtle indicator that an update is available until you do update.

Some Things About MappedSuperClass in ColdFusion 9.0.1

I was fooling around with inheritance in super classes in ColdFusion 9.0.1. I was trying to add that whole dynamic/static inheritance thing to Apptacular so you can add on to an Apptacular application without having to worry about changes being overridden by the regeneration process. Typically when you do that, the dynamic, rewritten class is usually the parent of the child static class. The child, static, class is what you refer to in the rest of code and in which you write custom code. The scaffolder never touches this file again, allowing you to alter things in the database, rescaffold and not overwrite code customizations. I hearby call this “non-destructive scaffold regeneration,” regardless of what other people call it.

ORM entities can’t really work that way. If you try to setup that sort of thing, ORM craps out in ColdFusion with an error. CF9 ORM doesn’t really like ORM objects being the parent of other items, unless you are using inheritance mapping.

However, if you use the “mappedSuperClass” cfc attribute that is now available in ColdFusion 9.0.1 you can achieve sort of the same thing, but you have to flip this on its head. The superclass is the one that is static, and you can edit, while the dynamic one is the child.

This is mostly good. Except for one thing: one of the main reasons to write code this way is so you can override methods, and if the child is the one that is dynamic, and overwritten, then you cannot override the methods from the static parent. You can add methods and properties, but you cannot override them.

At first glance this seems like a deal breaker, but it doesn’t have to be. Most generated ORM entities are light on code, because of implicit getters and setters. But those implicit getters and setters are exactly what you want to override in an ORM entity. However it turns out that explicit functions will always override implicit ones, even when the explicit function is in the super class and not the child class.

I put together a simple little demo to show this off:

http://gist.github.com/509846.js

Result from test.cfm:

GetFirstName = Yo

GetRealFirstName = Aiden

So it’s a little upside down, but if you want to do some non-destructive scaffold regeneration with ColdFusion 9 ORM, it’s a workable solution. Expect this to come to an Apptacular near you soon.

 

1 Day of Apptacular

24 hours after pushing Apptacular out, I have over 150 downloads, and only 2 reported problems.

Awesome!

One of the problems was that a user tried to run Apptacular against a database without primary keys. Apptacular and ORM in general have a dependency on primary keys. I should make that clearer in the documents, and error, and I will. But just know that.

In the meantime, keep downloading Apptacular and checking out my materials on it.

Get Apptacular

We’ll be releasing Apptacular soon on labs.adobe.com, but I’m tired of saying “It’s coming soon.”

You want Apptacular: Go get it: http://bit.ly/Apptacular

If you have any issues, please report them using this site: http://bit.ly/ApptacularIssues

If you want to participate in building Apptacular, you want to look at the source, and tests, etc. Check it out on GitHub: http://bit.ly/ApptacularGitHub

If you want to know more about what Apptacular can do for you, check out these tutorial videos:

Apptacular, onProjectCreate, and Annoying Database Conventions

Sorry for the MeatLoaf-esque title, but I have a video demo that shows off some new features of both ColdFusion Builder extensions in general, and Apptacular in particular.

onProjectCreate

One feature of extensions that hasn’t been getting any play is the fact that you can wire up your extensions to run after a project is created. At the end of the New Project Wizard you can choose from a list of all of the extensions that have this enabled, and run anything an extension can do. This is really cool for starting up your projects with your preferred structure and style right from the get go. The video demo shows running Apptacular in this manner.

Prefixes

ORM and databases are great together, but sometimes database conventions run afoul of ORM best practices. Take table prefixes for example. Having a table with tbl_user makes some sense on the database side, it’s basically Hungarian notation for tables. (I’ve also seen people append the schema name to the table, as in the video.)

As necessary as it may be on the database side, it’s a big pain on the ORM side. We don’t want to work with a tbl_user object, we want to work with a user object.

Apptacular allows you to set a prefix that you can have removed from any of your tables. In this case it will convert the table tbl_user to the ORM entity user. Very handy, and saves a lot of work.

Plurals

The other convention that gets in the way of generating ORM content from the database is plurals in tables. So table users should translate to the ORM entity user. I’ve added a checkmark option that will try and do that for you.

So these options combine to make writing clean, readable ORM from databases with these conventions really quick and easy. Check out the video to see this in action.

http://vimeo.com/moogaloop.swf?clip_id=10526198&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00ADEF&fullscreen=1

Apptacular ColdFusion Builder Extension – onProjectCreate, prefixes and depluralizing. from Terry Ryan on Vimeo.

Using ColdFusion and Flash Builder Together

Since the cat’s out of the bag on the fact that ColdFusion Builder comes bundled with Flash Builder, I thought it might be good to share some tips for using them together.

Flash Builder 4 for ColdFusion Developers

This video gives a little overview of using ColdFusion services with Flash Builder. It will show exactly how to pull them in and use them together.

Using Flash Builder 4 and ColdFusion Builder in an integrated workflow

This article goes over using ColdFusion services with Flash Builder. It uses ColdFusion Builder and Apptacular to generate back-end services. It then shows you how to consume them with Flash Builder. Yes, it uses Apptacular, so if you want to get your hands on that, there is a download link. The copy of Apptacular included in this article definitely works with the demo. Past that, I know I’ve added some bug fixes since then, so caveat downloader.

Apptacular Update and Video

I know I’ve been quiet of late. But I’ve been working.

You see a few weeks ago I had this checklist up on the site:

  • Make sure apptacular_blog database works on MySQL on MAC.
  • Make sure apptacular_blog database works on MySQL on PC.
  • Make sure sakila database works on MySQL on MAC.
  • Make sure sakila database works on MySQL on PC.
  • Make sure apptacular_blog database works on MSSQL on MAC.
  • Make sure apptacular_blog database works on MSSQL on PC.
  • Make sure adventureworks database works on MSSQL on MAC.
  • Make sure adventureworks database works on MSSQL on PC.
  • Fix major issues in code readability.
  • Start Document how to work with Apptacular

See those AdventureWorks database items? They nearly killed me and made me want to stop work on Apptacular. AdventureWorks is like a cruel Double Dare obstacle course for code generation:

  • Composite primary keys
  • Composite foreign keys
  • Composite primary keys that are also foreign keys
  • Custom Datatypes
  • Constraints (Really only affected unit testing).

I came through, and now I can give you this list:

  • Make sure apptacular_blog database works on MySQL on MAC.
  • Make sure apptacular_blog database works on MySQL on PC.
  • Make sure sakila database works on MySQL on MAC.
  • Make sure sakila database works on MySQL on PC.
  • Make sure apptacular_blog database works on MSSQL on MAC.
  • Make sure apptacular_blog database works on MSSQL on PC.
  • Make sure adventureworks database works on MSSQL on MAC.
  • Make sure adventureworks database works on MSSQL on PC.
  • Fix major issues in code readability.
  • Start Document how to work with Apptacular

So that’s where I am. A few of you asked if you could get your hands on Apptacular and I would be happy to distribute it to individuals. I’m not ready for general availability yet though.

And as a final note, I thought I would share this feature with you: Apptacular can model CRUD for image fields in your database.

http://vimeo.com/moogaloop.swf?clip_id=9159214&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=00ADEF&fullscreen=1

Apptacular ColdFusion Builder Extension – Working with Images from Terry Ryan on Vimeo.

Apptacular Plans

A few people have asked: When will Apptacular be released?

Short answer: I don’t know.

Long answer: I have a plan. Read on.

Before I release Apptacular, I want to make sure that it’s solid. Right now it works with the database I have but I know it will fall down when it hits a “real” database. The fix for that problem is to run it against demo databases that come with various RDBMSs. I’m targeting sakila for MySQL and AdventureWorks for MSSQL.

Also the source is somewhat hard to follow. There is no documentation. Most people won’t give a project a second look unless the documentation can at least get them started. Most potential contributors won’t even try to jump in unless the source is manageable.

So to those ends I have sort of a checklist to go through before I release the extension and code:

  • Make sure apptacular_blog database works on MySQL on MAC.
  • Make sure apptacular_blog database works on MySQL on PC.
  • Make sure sakila database works on MySQL on MAC.
  • Make sure sakila database works on MySQL on PC.
  • Make sure apptacular_blog database works on MSSQL on MAC.
  • Make sure apptacular_blog database works on MSSQL on PC.
  • Make sure adventureworks database works on MSSQL on MAC.
  • Make sure adventureworks database works on MSSQL on PC.
  • Fix major issues in code readability.
  • Start Document how to work with Apptacular

So I’ll keep you all up to date on where it is. If you want to test it ahead of time, and are willing to deal with bugs, then drop me a line in the comments.