Viewing by month: November 2007

Nov 26 2007

CF9 Feature Wish: Properties, please!

A long time ago, I did C# development. It was brief. I liked the language, but couldn't stand the project. The only good code that came out of it was Model-Glue and the the Alagad Image Component: Doug and I both had a lot of spare time during a 3-hour sync/build process that had to be performed manually.

That aside, one thing I loved about C# were its notion of "property" functions. Instead of writing getFirstname() and setFirstname() functions to hide the "firstname" property, you could simply declare a public firstname property. If you needed to implement data hiding, you could simply change "firstname" to a private mFirstname property and expose the public "firstname" by adding a getter and setter function:

private String mFirstname;

public String firstname {
   get {
      return mFirstname
   }
   set {
      mFirstname = value;
   }
}

ActionScript 3 has similar features. When I model a class, I typically start with all-public properties, shifting to getter/setter functions wrapping a private variable as needed:

private _firstname:String;

public function get firstname():String
{
   return _firstname;
}

public function set firstname(value:String):void
{
   _firstname = value;
}

Would it be that hard for ColdFusion to do the same? I'm tired of writing getter and setter functions (and writing and maintaining tools that do it for me). Other automagic solutions, such as onMissingMethod and mixins, result in what I call a "squishy" API: you don't know its form until runtime. Hard to document!

Here's something I'd love to see in ColdFusion 9:

<cfproperty name="firstname" type="string" />

...works exactly like now. It declares a property, but doesn't set it, just like "public var firstname:String". Developers work directly with instance.firstname.

When we need to "hide" data and have getter/setter logic applied, we can expand our property:

<cfproperty name="firstname" type="string">
   <cfsetter>
      <cfset variables._firstname = value />
   </cfsetter>
   <cfgetter>
      <cfreturn variables._firstname />
   </cfgetter>
</cfproperty>

The <cfsetter> tag is basically a <cffunction> tag invoked when a developer performs an assignment to firstname, receiving a single argument named "value." When the firstname property is accessed, the <cfgetter> function is invoked.

It'd require changes to the "under the hood" mechanics of accessing public-facing members of CFC instances, but I think it'd be worth it.

I've sent along a feature request to Adobe asking for this. If you'd like to do the same, visit the feature request form. If you'd like to do it quickly, without typing your own feature request in, simply visit the form, change "This is a:" to "Feature Request," and paste the following text into the text area describing this feature:

18 comments - Posted by Joe Rinehart at 8:25 AM - Categories: ColdFusion MX

Nov 21 2007

Flex Poll: When will Joe Rinehart's daughter be born?

As an example application, I've put together a little Flex application that lets you guess when my daughter (Ava) will be born called "What Will Ava Do?"

You can guess the date, time, weight, and length. Feel free to give it a whirl at http://firemoss.com/com/firemoss/avapool/ - I'd love to hear from you!

4 comments - Posted by Joe Rinehart at 5:18 PM - Categories: Flex | Off Topic

Nov 21 2007

RIAs at CFUnited: Wow!

Over on the CFUnited blog, Liz has posted the first 8 sessions chosen for the RIA track. They're a great set of topics, but there are five that we (Liz Frederick, Simon Horwith, and myself) all agreed formed a great series of topics for ColdFusion developers looking to build Flex and AJAX RIAs. If you're looking to learn more about this, here's how the five fit together.

These summaries aren't the presenter's abstracts: they're my understanding of the abstract submitted.

Simon Horwith's "CF Software Architecture for Web 2.0"

Simon's session starts with the foundation, showing "best practice approaches" for using CF to back Flex, AIR, AJAX, and LCDS apps.

Jeff Tapper's "Flex 3 and ColdFusion"

Overview of the ColdFusion/Flex technology via AMF/ RPC. Basically, how the two talk, what RemoteObject is, and how to have CFCs and AS3 Value Objects map together. Jeff's presentation builds on Simon's, showing the tech ins and outs of having ColdFusion and Flex communicate.

Joe Rinehart's "From ColdFusion to Flex: Model-View-Controller"

Now that folks of seen how the technologies talk (Jeff) and how to build the backend (Simon), Joe's presentation is about how to build the Flex (or AIR) frontend of a RIA. It's presented using correlations between how many ColdFusion developers already build HTML applications (using MVC) and how MVC can be done in Flex.

(I will not refer to myself in the third person.)

Matt Woodward's "Real World Flex and ColdFusion"

We've seen how they talk (Jeff), architecture for backend (Simon) and frontend (Joe), now Matt puts it all together, building an app with Flex components, Flex events, and an Object-Oriented ColdFusion backend.

Raymond Camden's "Ajax and CF"

Matt and Joe have rambled on about Flex, and now Ray will show how to use ColdFusion backends to power Ajax applications.

Conclusion

For the RIA track, we've got a great progression of sessions for developers looking to jump into building ColdFusion-powered RIAs.

Experienced RIA developers won't be left out: I can't wait to see Robi Sen talk about his take on continuous integration and testing with Flex (something I do, but not 100%), Rob Gonda on security, and Sandy Clark on accessibility.

1 comments - Posted by Joe Rinehart at 1:20 PM - Categories: Conferences and Speaking Engagements

Nov 20 2007

Firemoss turns One!

Today's the 366th day of Firemoss, LLC being a company my full-time job. Other than learning my lesson about not blocking off more vacation time, I've got no regrets.

This paragraph was supposed to thank my "customers." Over the past year, I've been lucky enough to work with multiple teams delivering great ColdFusion and Flex applications,. The experience has redefined how I feel about the word "customer" in the role of my business. It's actually hard for me to use. I feel more like we've been coworkers and teammates rather than a "customer" or "client" working with a "consultant" or "contractor."

Over the next year, I'm going to aim to keep this the goal of Firemoss: not being just a technical services provider, but a member of teams that produce great Web-based software.

Some time in the next few weeks, I'll be stopping regular work until January, as I'm going to be taking on a new role with the title of "Dad." Once I've taken a few weeks off, I'll be back to work doing Flex and ColdFusion applications, and I'll be putting the finishing touches on a new framework for an alpha release.

6 comments - Posted by Joe Rinehart at 1:35 PM - Categories: Firemoss

Nov 15 2007

Uber-customizable Flex "Loading Spinner" Component

I love loading spinners. I'm not sure why. Sometimes, when something locks up with a spinner going, I won't even notice.

In Flex apps, I've used one by "jake," but I had a few issues with it:

  1. It only spun a simple line.
  2. It was explicit (you had to tell it to start and stop) instead of allowing its "playing" state to be bound.

I was restless the other night, so I put together my own version, featuring the following:

  1. It'll take most DisplayObject instances as a "template" for what to repeat, so you can obnoxiously repeat and fade a Panel if you really want to.
  2. It allows the "playing" state to be bound.
  3. You can set (and change on the fly) the effect to apply to each repeated instance to any Effect instance.

In its simple, stock form, it's just a spinner:

However, spinning something else (like a Button) with custom effects can be entertaining:

It's not perfect (the stock "tick" for the spinner doesn't use CSS, etc.), but how much more overengineered could a loading spinner get?

Try it out and play with the parameters (view source enabled). Use at your own peril.

5 comments - Posted by Joe Rinehart at 3:02 PM - Categories: Flex

Nov 13 2007

Model-Glue group on ColdFusionCommunity.org

ColdFusionCommunity.org, a Facebook-like site for ColdFusion developers, is growing rapidly. Yesterday, Shimju David started up a Model-Glue group. It'd be great if it grew into an "unofficial" place to connect with and get to know other Model-Glue developers.

0 comments - Posted by Joe Rinehart at 7:36 AM - Categories: Model-Glue

Nov 12 2007

BeanUtils: First Firemoss open-source software!

Over the weekend, I pushed a library named "BeanUtils" out to RIAForge. I realized today that it represents the first full project released under an open-source license (ASL 2.0) that falls under Firemoss copyright.

It's not a framework: it's more of a tool for utility and framework writers who need to deal with discovering and manipulating properties of CFCs at runtime. It's something I've needed a few times, and I can see places for it within Model-Glue, ColdSpring, Validat, and other utilities that need to do this sort of manipulation.

Features

It provides the following utilities:

Property Inspection

Pass a CFC instance to inspect() and it'll tell you about all of its properties (as either a struct or XML), based <cfproperty /> and getter properties. Any extra attributes added to the relevant <cfproperty /> or <cffunction /> tags will also be included. You can choose to cache results of inspection (by CFC type name) or have it reinspect on each request (to handle things like mixins).

Property Extraction

Pass a CFC instance to extract(), and it'll crawl through the THIS scope and call getter functions as necessary to build a structure of the CFC's data. Safely handles recursive references, even within arrays and structs, building out recursive data structures as a result.

Property Injection

Pass a structure and a CFC to inject(), and it'll set the CFC's properties from like-named members of the structure. It'll populate single "has-a" relationships, but won't populate things like arrays of CFCs (how would it know what "child" CFC to create?). This might get enabled through an optional additional inspection strategy that recognized an attribute like "collectionOf" on array and structure properties (see below bits on "Have it Your Way").

Property Setting

If you don't know the name of a property to set until runtime, setProperty() accepts the name as a variable. It's smart enough to know if it should use the THIS scope or call a setter function.

Property Getting

Similar to setProperty(), getProperty() will get a property by a variable name, using the THIS scope or calling the appropriate getter function.

Have it Your Way

A lot of semantics go into determining what is a property, whether or not its extractable, how a query should be represented in an extraction (right now, it's just a query, but you may want an array of structs, etc.)

For this purpose, BeanUtils is really just a facade on two lower level components: an Inspector and a Convertor. Inspectors discover properties, and Convertors handle the injection / extraction of data.

As this is a fairly low-level tool, it's not likely to be widely used or documented. If you need it, you know it already. I've been very good about using the HINT attribute, so the API should be fairly straightforward.

0 comments - Posted by Joe Rinehart at 3:32 PM - Categories: ColdFusion MX | Firemoss Tools and Products