Flex Pasta » 2008 » June

I ponder a simple Cairngorm vs. Penne example. I want to add on to the Italian Store(find the code under Introducing The Penne Framework). I want to add a feature to the application to allow the user to delete a pasta type.

Using Cairngorm:

  1. Add a trash can to the datagrid.
  2. Add a new class DeletePastaTypeEvent.
  3. Implement the clone method with the deleted pasta type as payload. Create a static variable for the event type making sure the “type string” hasn’t been used anywhere else.
  4. Invoke the event from the trash can click handler.
  5. Add a new DeletePastaTypeCommand.
  6. Add a new method “deletePastaType()” in the PastaTypeDelegate Class.
  7. Add a line in FrontController mapping the DeletePastaTypeEvent to the DeletePastaTypeCommand.
  8. Fill in all the execute, result, fault methods in DeletePastaTypeCommand with the cookie cutter code.

Eight steps, which doesn’t even include having to add or change a model locator.

Using Penne:

  1. Add a trash can to the datagrid.
  2. Add a new method “deletePastaType()” in the IPastaRemoteRq, implementing it in PastaRemoteRq.
  3. Add a new method “deletePastaType(pastaTypes:ArrayCollection)” in the IPastaRemoteRs, implementing it in PastaRemoteRs.
  4. Invoke the request method from the trash can click handler.

Twice as many steps in Cairngorm vs Penne. Penne also required no class creation, vs two with Cairngorm. When looking at my datagrid in Penne, I can click right through to the deletePastaType and see what is happening. With Cairngorm, I have to dig up another file, DeletePastaTypeCommand.

I welcome your comments and feedback.

Whether I am tracking how long a user’s session lasts, trying to decrease JVM memory usage, or am debugging a user’s problem, I want to know, and end immediately the user’s Java session when they(the user) logs out of my flex application. When they click my big red “Log Out” button like every good user is supposed to then I can end the user’s session easily by calling a remote service that does

try
{
FlexContext.getFlexSession().getSession(false).invalidate();
}
catch(IllegalStateException i)
{
System.Out.Println("I'm trying to invalidate the session but it seems to be dead already. Oh and I'm also using System Out which is not such a great idea, but hey, this is just an example!!!");
}

Now evil Sam comes along and doesn’t press the nifty log out button I so thoughtfully left for him. Instead he navigates away or closes his browser. How to catch this in flex? First, I must have an html wrapper around my swf file. If I don’t, this solution has no basis. In the html wrapper file, find the body tag and add an “onunload” attribute.

<body onunload=”MyFlexApp.myFlexFunction();”>

Then in myFlexFunction(the one inside your swf), I can call the normal Logout service just as if they pressed the logout button.

With the explosion of Flex leading the way in web 2.0, I often wonder, 5 years from now, will Flex dominate the RIA landscape?

What Flex has going for it:

  • A great looking UI out of the box
  • Adobe: A big corporate name investing money in its promotion. While free ajax frameworks are great as well, there are a lot of options out there that clutter the picture of a front runner against Flex.
  • BlazeDS - AMF. It is proven to be the fastest web 2.0 transfer and rendering framework out. It also makes coding easy for Java developers.
  • It is open source! Yes, Flex Builder does cost money, but for corporations wanting an enterprise RIA, this is nothing. The important thing is that the code is available for the community to improve.
Pinky & The Brain

Where Flex struggles:

  • Marketing: Nobody knows about Flex! While this is improving, many people, developers, managers, CEOs, etc have never heard of it! If they hear about it, they would probably be using it. Adobe should run a Super Bowl commercial. Flex doesn’t apply to the general audience, but hey, GoDaddy has Danica Patrick doing Super Bowl Ads. If the general audience registers websites then their next step would be making the website. Maybe Pinky and The Brain could be the spokesmice?
  • The Google Effect. It is why this blog and every other blog is NOT written in Flex. Google and other search engines can’t read them! They can’t read the text or the cool drag and drop features they might do. AJAX sites are limited web crawlers as well, but not as much as Flex.

Great Points, but I’m a little scared by this Pinky and the Brain stuff. What is it?

Pinky and the Brain is an emmy winning cartoon with the following theme:

Pinky: “Gee Brain, what do you want to do tonight?”
The Brain: “The same thing we do every night, Pinky- try to take over the world.”

Check out the intro on youtube: