David Harris's Technology Blog

ColdFusion, Flex, and other stuff...   (and 341,536 hours, 32 mins in to my plan for global domination)

Search:

Calendar:

Sun Mon Tue Wed Thu Fri Sat
        1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

Subscribe:

Enter your email address to subscribe to this blog.

Archives By Subject:

Tags:

action script adobe air ajax cfug coldfusion flash flex frameworks free software fxug general jpgmetadatareader mac off topic opensource papervision spry

Recent Entries:

No recent entries.

Top Posts:

Recent Comments:

Top Commenters:

My Links:

RSS:


CfObjective Downunder

I've been a bit slow in blogging, but thanks to a hard working team, CFObjective is coming downunder!

They have secured a stelar line up of speakers, from both down under and up-over!

CFObjective is "The Only Enterprise ColdFusion Conference", so expect a lot more than intro sessions here!

Website: http://www.cfobjective.com.au/

Twitter: http://twitter.com/cfobjective_anz

Adobe Community Road Show Coming to Auckland!

This Thursday http://www.cfug.org.nz/ and http://www.fxug.org.nz/ are hosting an Adobe Roadshow event with Mark Szulc.

Come along to hear more about Flash Builder, Flash Catalyst and CF9!

I will attempt to broadcast the meeting on http://experts.na3.acrobat.com/nzcfug/, all going well!

Related Links:

http://groups.adobe.com/posts/1b5f77b054

http://nzroadshow.eventbrite.com/

http://labs.adobe.com/

See you there!

ColdFusion and constants - how do you do them?

I've been working on a project a bit lately and found I've had the need to use some constants.

This has gotten me thinking how to implement them.

When work in Flex, I use the Extensions for Adobe Cairngorm and when creating your custom events involves you declaring constants in the event. The consts in the event are related to the Event type.

The idea behind constants is that this is information that *will never change*, hence the name "constants" :-)

In the CF application I've been working on, UUIDs are used, and there is no way you can call a UUID "human readable", so this can make code harder to understand when you see something like:

<cflocation url="/index.cfm?page=70688909-1676-D9C3-F2C5B9F163AEBDCF ">

If you want the person who reads this code later understand which page that is with out having to pull the application apart (and hair out too sometimes), you might to this:

<cfset uInfoPage = "70688909-1676-D9C3-F2C5B9F163AEBDCF">
<cflocation url="/index.cfm?page=#uInfoPage#">

That way the name of the variable will indicate *what* that UUID value indicates.

With me so far?

"But Dave, my application has more than one template and I don't want to have to do that every time I want to send a user to the info page, and what happens if the UUID of the info page changes?" you cry.

Well, why not have a single "thing" that stores all your constants that you can store in one place and use everywhere?

What I started doing here is I created a "Const.cfc" that had getter functions on them to return the constants. EG:

<cfcomponent output="false">
<cffunction name="getInfoPageUUID">
<cfreturn "70688909-1676-D9C3-F2C5B9F163AEBDCF">
</cffunction>
</cfcomponent>
So the previous code can be done as:
<cflocation url="/index.cfm?page=#oConst.getInfoPageUUID()#">
(to be honest, I'd actually drop the "get" on the function name and just call it "InfoPageUUID", as it is a const and there is no "set", so why "get"?)

(Another note: I'd usually declare/call the function in all CAPS too, as this is the "standard" way of naming constants)

The above relies on "oConst" being created, which could be stored in application scope for example.

What I didn't like about this is that the actual value is hidden from my old friend "cfdump", and if I have alot of constants I can't see their values in one hit.

This lead me to the "this" scope of my CFC(s).

Something like this:

<cfcomponent output="false">
<cffunction name="init">
<cfset this.INFOPAGEUUID = "70688909-1676-D9C3-F2C5B9F163AEBDCF">
<cfreturn this>
</cffunction>
</cfcomponent>

...which them means the example code can be written like this:

<cflocation url="/index.cfm?page=#oConst.INFOPAGEUUID#">

Before you cry "But people can change the values in the 'this' scope and break stuff!", I've always thought if people want to do that, it's up to them, but don't come running to me if it breaks! (Also, CFCs are not secure at all anyway! see related entry)

The two things I like about using the "this" scope for constants are:

  • 1: You can see all the values if you cfdump it
  • 2: If you CFC has functions, you don't have lots of functions to work out that don't really do anything

Let me explain the second point a bit further.

Imagine I have a DB table that stores information of pages on my site. My CFC has functions to work with this data. In my application I have 1meeeeeeelllion UUIDs to do with various parts of the application, that are used in various ways, that would help the readability of my code if they are stored as constants. This would render the "One Constant.cfc to rule them all" a bit hard to manage. What I have been doing is storing the UUIDs to do with that part of the application in the CFC that deals with that part of the application.

EG:

<cfcomponent output="false">
<cffunction name="init">
<cfset this.INFOPAGEUUID = "70688909-1676-D9C3-F2C5B9F163AEBDCF">
<cfset this.HOMEPAGEUUID = "70826CD8-1676-D9C3-F256954C82CAF104">
<cfreturn this>
</cffunction>
<cffunction name="doSomething">
</cffunction>
<cffunction name="doSomethingElse>
</cffunction>
...lots more functions here...
</cfcomponent>

If you create that cfc and dump it as below:

<cfset oMyObject = createObject("component","someCFC").init()>
<cfdump var="#oMyObject#">
by default (CF8 I think...) I would see all my constants at the top and all my functions would be collapsed.

Given the above code uses no frameworks and if any of you managed to read all my brain dump, what thoughts do you have on the above and/or how have you approached ColdFusion constants?

Disclaimer: all the above code is psedo code and hasn't actually been tested, but feel free to point out syntax errors etc. I may change it, I may not...

Transfer: Something I like about it.

I've been looking in to Mark Mandel's Transfer bit since he presented to the http://www.cfug.org.nz end of last year.

One thing (of the many things) I like about it is the XML config file.

Why do I like it?

2 reasons.

1. The fact you can introduce some form of package.class hierarchy to the Database, so flat database's can be organized better EG:

<transfer>
<objectDefinitions>
<package name="mypackage">
<object name="myclass" table="mytable" >
<id name="id" type="UUID" />
<property name="my property" type="string" />
...etc...
So this means I call my "myclass" like this:
transfer.getTransfer().new("mypackage.myclass");

2. The second reason is: I CAN COMMENT THE XML! Why is this good? I'm sure we have all returned to database tables with a few to many columns and tried to would out what "status" column and "anotherStatus" column actually relates to in the business logic of the application. This process involves digging through code and random comments. With the XML config of transfer, a simple comment on the property can explain it so the next person who needs to work with it knows where look to find out what the class (db table) is for and what purpose the property servers.

Hopefully I'll find the time to blog some examples on Transfer later.

EG: Event model and decorators

NZ CFUG: Mark Mandel on Transfer

Only 2 days till the next NZ Cfug meeting.

This month we are going to have Mark Mandel giving us his "Introduction to Building Applications with Transfer ORM" presentation live via Adobe Connect.

We attempted to have this last month, but due to technical issues last month [cough]VPN[cough] Mark agreed to give it this month.

This month we are meeting for the first time at ProjectPartner, so a big thank you to them!

The meeting will be broadcast via Connect on the URL http://experts.na3.acrobat.com/nzcfug/, so feel free to sit in if you are round @ 6pm (NZ time) on the 6th November.

If you RSVP (remote or in person) and are based in NZ, you'll be in the prize draw too!

RSVP: http://nzcfug.eventbrite.com/

See you there!

Adventures in jQuery

The last week or so I've had the pleasure of working deeply with jQuery.

And I mean that, it's been a pleasure.

Once you get used to the 'style' of how it works, it makes sense and has a consistent coding experience.

I've worked mainly with the core and the ui.jquery libraries, with fileupload thrown in. In the mix is also , and they have all played together nicely (so far!)

I've got jQuery adding and removing custom DOM elements on the fly, while updating information on the server, uploading and deleting images and also maintaining the structure of the form so that when it is submitted in the usual "post" manner, the server knows what to do with the data it receives.

So all in all I've had a good experience with it.

Things it has helped me understand is the use of "anonymous Functions" (I think that is what they are called)

EG:

$("#myelement").hide();
will hide the element with the id of "myelement"

now the "hide" method will accept an argument of a function that it will call when it has completed. Commonly called a "callback", so i we had a function like this:

function alertme(){ alert('me'); }
you could call that function when hide was complete like this:
$("#myelement").hide( alertme );
so the function has the name "alertme", so is not anonymous.

To use an anonymous function to do the same thing, this is what you would do:

$("#myelement").hide( function(){ alert('me'); } );

You can also do this in Flex.

eg:

rather than:

addEventListener( "SomeEvent" , someFunction );
You can go:
addEventListener( "someEvent" , function( event: Event): void { [do stuff here] } );
While you can put as much in you function as you like, I did find it makes code a bit hard to read.

One thing that works, but somehow feels wrong, is that the anonymous functions have direct access to the variables declared in the calling function.

eg:

function myFunction()
{

   var someString = "bob";
   $("#myelement").hide( function(){ alert( someString ); } );

}
This seems to be true of both JS and AS. I guess this is because the function itself belongs to the function it is being called in, so has access to the variables called in there...

So all in all I've enjoyed getting to know jQuery, and suspect it's the beginning of a beautiful friendship!

...but, I still prefer Flex!

CF8 Ajax Goodness - Ray Camdens Recording

Tonight we had the honor of Ray Camden staying up till 1am his time to present to us @ 6pm NZ time.

The meeting was the NZ ColdFusion UG June meeting, and the topic was CF8 Ajax Goodness

After a couple of technical issues (involving screen issues and incorrect Connect meeting rooms on my part...*cough*) we got the meeting under way.

Ray, as always, gave a great presentation which promoted good discussion in the group afterwards.

So a big thanks to Ray for his continued giving of time and energy to the community!

The recording URL is https://admin.adobe.acrobat.com/_a200985228/p21985414/ and I have also added it to UGTV

Enjoy!

ColdFusion 8.0.1 fixed my bug!

I while ago I logged a bug for the first time with in ColdFusion 8.

Here is the entry about it.

While looking over the 8.0.1 release notes I decide to check...

and yes, at the top of page 15, bug number 70594 has been addressed! Thank you!

Transfer 1.0 ORM is released!

Just noticed this on a mailing list:

Transfer 1.0 Release Candidate - Out Now!

Well done Mark!

Mark presented to the NZCFUG last year on TransferORM.

I'll be downloading Transfer 1.0 soon to have take it for a spin!

ColdFusion Error: can't load a null

I was working with a CFC today and ColdFusion threw this error at me:

can't load a null

There was no more information than that...

I'm not sure why is this error happens, but I did work what is causing it...

If you define a function that has an argument that has a default that is a variable or function with the same name as any of the arguments, this error is thrown.

You don't even need to call the function, you just need to define it.

Create a .cfm or .cfc and put this function in it:

<cffunction name="someFunction">

   <cfargument name="myValue" default="#myValue#">

   <cfreturn false>

</cffunction>

The error is occurring when ColdFusion is parsing the code, and not running it.

Weird eh?

I'm off to http://www.adobe.com/go/wish now to log a bug (all-be-it an obscure odd one...)

I know what DSL is now, thanks to Peter Bell!

Last Thursday at the NZ CFUG group we tried something new.

For the first time we watched a recording of a Connect meeting and had discussion about it once it finished.

After voting by the CFUG members for the topic, "Practical Code Generation" by Peter Bell was chosen.

About this Presentation (taken from UGTV):

A 20-30 minute preview session of my full session where we'd learn how to generate your applications in a fraction of the time by using the latest techniques proven to reduce application development times - from Software Product Lines to Domain Specific Languages.

The meeting was given to the "Online ColdFusion User Group" a couple of months back.

I've heard the phrase "Domain Specific Languages" (DSL) thrown round a bit and generally I nodded my head hoping the person using it wouldn't ask me about it, as I didn't really know what it meant...

In the presentation Peter took some pains to explain what a DSL is and how they can be used in code generation.

I found it to be a highly information presentation, so kudos to Peter Bell for this and also Charlie Arehart for running (and recording) the meeting

The link to the recording is here: https://admin.acrobat.com/_a204547676/p26665304/, so have a look when you get a chance!

PS: there can *never* be enough TLA's in the world! *NEVER*!

More Entries