I have spent the past month working with flex - and thought I would blog all the things I have learnt

I am used to object orientated languages such as java (and nowdays even php). All languages have started to look very similar with object orientated dot notation etc. Actionscript (as3) also falls into this category.

I have worked with spring ad java - and am used to xml that can be used to wire java objects together.

Lesson 1) The first difficult part about flex is to get used to the concept that the ActivityPopup.mxml actually creates a new class called ActivityPopup which can be referenced as a normal class in your code. You have a totally new class - but there is <code>no public class ActivityPopup {</code> anywhere to be found.

(You can use the compiler option "-keep-generated-actionscript" to keep the actionscript that is generated from the .mxml files if you want to see what is happening)

Lesson 2) When using flash builder, you may receive a message that the application is already running but the application is not visible. Use task manager to kill adl.exe (adobe debugger) . This will resolve the issue.

Lesson 3) If you are working with a new project - make certain you use the newer sdks (4.1 + ) - as older sdks have many issues (for example: licensing hassels with the visualisation libraries).

Lesson 4) Learning by create a fresh project and using examples from a recent book. The quality of examples found via google can be poor. Some do not work, many encourge poor programming. If you are new to flex, its difficult to know what is good technique. You have to get used to the basics before you can start adding advanced features.

Lesson 5) The [Binding] parameter allows components to listen (and respond) to changes on a data source. The datasource needs to have [Binding] keyword over the definition of the parameter to make it bindable.

Lesson 6) I just expect the component to data binding to work for both reads(component reads datasource and presents data) and writes(changes by user in component, automatically writes to the data source it is bound it). This is not the case. Writes to not write back to the data model.

Lesson 7) Its better to have a central model singleton which contains all the data context the user is in. Then bind the components to this model. You can use


[Bindable]
private var model:ModelLocator = ModelLocator.getInstance();

Lesson 8) Use some form of hungarian notation to help you seperate objects that are created by flex(magically in the background) eg. checkBox_IncludeMasterEntityName

Lesson 9) For you first project avoid one of the frameworks. I added parsely ioc framework to the code I was working on. These frameworks come with significant learning overhead if you are new to flex. I ended removing parsley from the code - because it actually made it harder understand the code. I would like to try robot legs framework as I think it will make more sence to me - its more OO inheritance based rather than special [tags] in your code.

Lesson 10) Write use OO classes to model your problem domain and use flexunit tests to test business logic - so you dont have to keep on testing it though the UI

Lesson 11) Assuming you are accessing a database directly - Get your relational database model right. Having a bad relational model and refusing to fix that can result in lots of hacks in your code.

Lesson 12) When you see references to @name  - this is short hand for referencing properties in a xml node.

Lesson 13)  you can use spark and mx components together by

<?xml version="1.0" encoding="utf-8"?>

<s:Panel

xmlns:fx="http://ns.adobe.com/mxml/2009

" xmlns:s="

library://ns.adobe.com/flex/spark"

xmlns:sf="http://www.spicefactory.org/parsley

"title="

Receive Panel" >

Found this great set of blog entries on how to get QTP and flex atomated testing to work

http://www.benlondon.co.uk/search/label/QTP

In summary some things to watch out for

Repeat/Summary of the obstacles encountered are:

  • must have ‘-includes=RandomWalkDelegate’
  • you have to make certain you run the Adobe Flex 4 Plugin for HP QuickTest Pro\Install_QTP_Plugin.bat to install the each time you change the TEAFlexCustom.xml or TEAFlex.xml file.
  • You have to restart QTP
  • You have to use the -include-libraries in additional compiler arguments
  • -include-libraries "C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\3.5.0\frameworks\libs\automation.swc" "C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\3.5.0\frameworks\libs\automation_agent.swc" "C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\3.5.0\frameworks\libs\qtp.swc" "C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\3.5.0\frameworks\libs\automation_dmv.swc" "C:\Program Files\Adobe\Adobe Flash Builder 4\sdks\3.5.0\frameworks\libs\automation_flashflexkit.swc"
  • The version of RandomWalk had to be patched as per http://raniskumar.wordpress.com/2009/09/09/flex-automation-random-walk-replay-error/
  • add Wait(5) commands in the QTP generated script to get it to work

 Spent quite a lot of time getting Flex automation working with the RandomWalk example - there where several obstacles to recording but now playback is failing.

This is with the latest version of the flex SDK (flex sdk 4.1 – build 16076)

it gives the following error:

AutomationManager:pushMouseSimulator() – In Air we are not allowed to do this on the Window object. We need to settle this with AIR team
Error #1009: Cannot access a property or method of a null object reference.: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at mx.automation::AutomationManager/replayMouseEventInternal()[C:\work\flex\dmv_automation\projects\automation_agent\src\mx\automation\AutomationManager.as:2557]
at Function/()[C:\work\flex\dmv_automation\projects\automation_agent\src\mx\automation\AutomationManager.as:2708]
at mx.automation::AutomationManager$/map()[C:\work\flex\dmv_automation\projects\automation_agent\src\mx\automation\AutomationManager.as:308]
at mx.automation::AutomationManager/replayClick()[C:\work\flex\dmv_automation\projects\automation_agent\src\mx\automation\AutomationManager.as:2710]
at RandomWalkDelegate/replayAutomatableEvent()[U:\projects\FlexMonkeyRandomWalk\src\RandomWalkDelegate.as:96]
at mx.core::UIComponent/replayAutomatableEvent()[E:\dev\4.x\frameworks\projects\framework\src\mx\core\UIComponent.as:12432]
at mx.automation::AutomationManager/replayAutomatableEvent()[C:\work\flex\dmv_automation\projects\automation_agent\src\mx\automation\AutomationManager.as:1405]
at com.gorillalogic.aqadaptor::AQEventDescriptor/replay()[C:\cygwin\home\pbirnie\flexmonkey-read-only\aqadaptor\src\com\gorillalogic\aqadaptor\AQEventDescriptor.as:94]
at com.gorillalogic.aqadaptor::AQAdapter/replayEvent()[C:\cygwin\home\pbirnie\flexmonkey-read-only\aqadaptor\src\com\gorillalogic\aqadaptor\AQAdapter.as:546]
at com.gorillalogic.aqadaptor::AQAdapter/replay()[C:\cygwin\home\pbirnie\flexmonkey-read-only\aqadaptor\src\com\gorillalogic\aqadaptor\AQAdapter.as:594]
at Function/()[C:\cygwin\home\pbirnie\flexmonkey-read-only\aqadaptor\src\com\gorillalogic\aqadaptor\AQAdapter.as:625]
at com.gorillalogic.aqadaptor::AQAdapter/useErrorHandler()[C:\cygwin\home\pbirnie\flexmonkey-read-only\aqadaptor\src\com\gorillalogic\aqadaptor\AQAdapter.as:801]
at com.gorillalogic.aqadaptor::AQAdapter/run()[C:\cygwin\home\pbirnie\flexmonkey-read-only\aqadaptor\src\com\gorillalogic\aqadaptor\AQAdapter.as:618]
at com.gorillalogic.flexmonkey.monkeyCommands::UIEventMonkeyCommand/run()[/Users/jonr/projects/flexmonkey/workspace-clean/flexmonkey-public/MonkeyLink/src/com/gorillalogic/flexmonkey/monkeyCommands/UIEventMonkeyCommand.as:115]
at com.gorillalogic.monkeylink::MonkeyLink/respondRunCommand()[/Users/jonr/projects/flexmonkey/workspace-clean/flexmonkey-public/MonkeyLink/src/com/gorillalogic/monkeylink/MonkeyLink.as:212]
Sending respondUiCommandReturn to _flexMonkey w/TXCount=2

This occurs for QTP, FlexMonkey and RiaTest
The same code works for sdk 3.5
I am using the version of RandomWalk with the patch from this flex automation experts blog – so I am 99% certain its the inside the AutomationManager or perhaps there is another patch required for RandomWalk code

I have only had my HTC desire for over 1 month and managed to full my SD card. (I previously have also run out of onboard memory for apps - but that issue should be resolved by the Froyo release of android - where I will be able to store applications on the SD card).

The full SD card problem - is different in that I know I have K9 mail installed and loads of other apps. I also thought the problem might have been caused by accidentally recording a very long video. I spent a lot of time looking for a app in the market place - but had no luck. Eventually I attached the phone to my macbook (using the USB cable) and pointed Jdisk report to my /Volumes/No Name on my mac to get a pie chart of my SD cards disk usage. It was doggcatcher (a podcast downloader) that is using all the disk space.

insane complexity in finding the black and white option - does apple get a kickback from HP on the number of color print cartridges used!?

I spent an hour messing around trying to get HP device manager to communicate with my HP C4380 all in one printer/scanner

It was working before I upgraded to Snow Leopard - I found several articles stating that you can just download the latest drivers and recreate the printer - this did not work for me. turns out the easiest is to not use the HP device manager - and simply use the 'scanner' tab when you list the printers details in apple->system preferences->printers->c4380 tab

( "photo by Jeff Kubina")

London startup - I think these guys are will do well - great for navigating orgcharts and finding 'stakeholders' and experts

Their website

crunchbase data ...

a video

(photo credit to flickr:louisvolant)

Just spent the last 2 days solid playing with my new HTC desire from 3

I was previously on 02 for 10 years but their network is overloaded due to the number of iphones on their network (this is largely due to the now expired iphone-02 exclusive deal in UK).

I must have installed over 50 apps - I still don't have 'skype lite for 3' working - its doesnt support the HTC Desire yet - will wait a few weeks and give it another go.

Due to issues with battery life I have ordered one one these portapow usb battery extenders that is rechargeable - will have to write a review on it once I have tried it out.

I have also ordered a Epik HTC Desire protector case for the phone from Hong Kong as a lot of the cases are available are actually for the Google Nexus One - like the FlexiShield do not fit correctly. Over 50% of the phone cases seem to be sock-style or folder-style - which doesnt seem like a good idea. How are are supposed to be able to answer the phone quickly? Anyway will have to wait and see if its a good choice

view from plane

These are some of the tips I have come up with when I fly longhall:

  • for longhall flights prebook seats away from toilet doors - either on isle or window
  • check-in as early as possible
  • pack one set wax earplugs
  • one set sleeping pills
  • wear lightweight trousers - no jeans as its hard to sleep in them
  • take one hardcover notebook - I use this if I get someone whos arms go over the armrest onto my side - you can end up with someone elbowing you in the ribs the entire flight - I place the book on my side of the seat between myself and armrest as a guard from their elbow
  • remove any magazines in front of you - this can give you another 1cm+ of leg space

Flickr has built in photo printing - but they charge 9p per print. http://www.photobox.co.uk charge only 5p per print. I used the flickr organiser to create a new flickr set called 'to print', then logged into photobox, chose 'from flickr' and the 'sets' tab' and then simply pressed the 'add all' link. [at the end of the photobox checkout process I discovered that 5p per print is actually a lie - its 9p per print with photobox - you may as well use the built in flickr photo printing]

I want to keep facebook as my default photo store - and just push some photos to facebook. This bookmarklet works very well for that purpose.


Photo by Scragz

  • use bind variables
  • restrict the rights of your web apps database user - no more rights than necessary (ie. no drop/create)
  • in production mode, when a sql error occurs, only show a message such as "an error occured" - not the full sql that was executed
In this podcast 'Joel Spolsky' makes the point that the title 'Software Architect' shouldn't really exist and that designing high level software interaction is just part of a good developers job.

  • ...are unsure that the title "Software Architect" is a good one. We're leaning towards it being almost.. a net negative. "It's almost disrespectful of the actual architects who work in construction, to use that word to refer to some kind of high-falutin' big-picture UML-drawing code monkey."
  • To the extent that the architect is not in the trenches with you doing the work, they don't have enough context, and will inevitably make the wrong decisions.
  • If we had the power, we'd do away with the title "Architect". But if you're stuck with it -- and the architecture astronomy that it frequently engenders --  what is the proper role for a so-called Architect? They could work to connect disparate groups at large organizations, to provide context and reduce duplication for disparate groups that are working in isolation. It can be hard for groups working locally to see the context of the larger organization. But I traditionally think of this role as an evangelist and educator, not an architect.

I think its good to question - Joel has his own small business - so he probably doesnt get any exposure to the change management and political war-ing of large orgs - which I think the title 'architect' helps with in order to get a product adopted by the org.

For a specific software product - I think the only way you can work on architecting some software is if you are involved working at the coal face (to gain respect of the developers and understanding of the problems) or at an extremely high level with some kind of enterprise architecture blocks for 'out of the box' products like SAP.

This Puppet vs Chef article is a great example of a how a well seo-ed blog can affect the opinions of many. If you look at the initial article in a quick 'skim read' to choose a technology - you would conclude that Puppet is the best option. However there are plenty of comments below the article specifying why the article is FUD.  I have come across this before when reading about cassandra - I later discovered from an expert inside Yahoo! that a lot of the information was incorrect.

installing Chef on ubuntu - I will be interested to see if its better than Yahoo's internal tools for configuration management.

I can really sympathise with this graphic designer - the media industry is full of people asking freelancers for things as cheap as possible.
Promising things like 'do this one cheap and there will be lots of future work' - which either doesn't materialise or is also at the same price.
I think it may also be linked to the recession - lots of people getting connections to do things for free as a favour because we don't have any money at the moment. I know of a SEO, who eventually had to refuse providing advice to anyone as he was over run with favours to people.

The growth of websites like elance.com also means a freelancer in London has to compete with - for example someone in a remote country, working from home, paying no tax. The cost of living in London means - that its basically impossible to sustain yourself on small projects. Each project has a unpaid lead time - in which you are collecting requirements and providing a estimate. Often small projects come with unpaid post project support. Getting requirements out of non-technical clients is a scary process where you discover whey didn't really know what they needed. Often you may find yourself helping them with their requirements, only to discover you are just telling them to use a specific tool or webservice. Thats all cool - but living in London you can burn through cash making you feel like you are in 'free fall'

I guess its time to refresh my sql - moving into finance means I could be running a lot of adhoc sql queries.

I am convinced I have used correlated subqueries before but had never heard of the term.
A correlated subquery is a query where the subquery uses values from the outer queries where clause.


SELECT empnum, name
FROM employee AS e1
WHERE salary > (SELECT avg(salary)
FROM employee
WHERE department = e1.department);

e1.department joins with the where cause of the other query.

This causes the query engine to execute the inner query for each match on the outer 'where' cause
This could produce some very inefficient queries. I guess as a programmer you can think of it as a 'for loop' - as in get all the data matching the where cause, loop though each row and perform another query.


mysql> select * from employee;
+------+-------+--------+---------------+
| id | name | salary | department_id |
+------+-------+--------+---------------+
| 2 | paul | 101 | 1 |
| 1 | bob | 100 | 1 |
| 3 | randy | 300 | 2 |
| 4 | sally | 305 | 2 |
+------+-------+--------+---------------+
4 rows in set (0.00 sec)


mysql> SELECT avg(salary) FROM employee
-> ;
+-------------+
| avg(salary) |
+-------------+
| 201.5000 |
+-------------+
1 row in set (0.06 sec)


mysql> SELECT id, name FROM employee AS e1 WHERE salary > (SELECT avg(salary) FROM employee WHERE department_id = e1.department_id);
+------+-------+
| id | name |
+------+-------+
| 2 | paul |
| 4 | sally |
+------+-------+
2 rows in set (0.00 sec)

The above query gives employees who have above average salary.

It much more effient to create a in memory table called a derived table called sal_ave using the syntax 'AS':

mysql> select name from employee e, (SELECT department_id, avg(salary) salary FROM employee group by department_id) AS sal_ave where e.salary > sal_ave.salary and e.department_id = sal_ave.department_id ;
+-------+
| name |
+-------+
| paul |
| sally |
+-------+
2 rows in set (0.00 sec)

Another common question in interviews is what is the difference between a WHERE and a HAVING cause

"HAVING specifies a search condition for a group or an aggregate function used in SELECT statement.

HAVING can be used only with the SELECT statement. HAVING is typically used in a GROUP BY clause. When GROUP BY is not used, HAVING behaves like a WHERE clause.

A HAVING clause is like a WHERE clause, but applies only to groups as a whole, whereas the WHERE clause applies to individual rows. A query can contain both a WHERE clause and a HAVING clause.

The optimizer always automatically analyzes each statement you enter and selects an efficient means of executing it. In general, that means eliminating undesired rows in earlier clauses."

The problem with the flare prefuse library is that flare is a commonly used word - so searching for examples on google results in a lot of matches other uses of the word flare. A simple solution is to use site explorer to find links to the flare prefuse website - this naturally disambiguates the meaning.

I found this link confirming to that flare is the best tool to be using  for now

"Yes, but how heavy is Axiis? Have you pushed the limits? I used Ravis Birdeye for our initial efforts for my network mapping app http://www.flairjax.com/?p=72, but the mxml components are way to heavy. Had to go to flare."

  I found this  classification of different types of visualisations

  • data visualisation - numbers in a graph, pie chart, barchart, scatterplot (quantitative data)
  • information visualisation - interactive visual reprentation of information in order to improve cognition
  • concept visualisation - mindmaps and other representations of concepts (qualitative data)
  • strategy visualisation - company strategy - (I dont understand how this in a classification similar to the others listed here)
  • metaphor visualisation - use a metaphores such as tree or landmass to represent something completely different
  • compound visualisation - something that uses a fixture of the above techniques

I think a better classification of a visualisation would be

  1. Is the visualisation user interactive?
  2. Does it represent a moment in time or a change over time  (does it have a time dimension)
  3. Does it contain quantitative data (numbers)
  4. Does it contain qualitative data (opinions of concepts - based on subjective or intangible ideas such as "warmth" or "friendly")
  5. Number of physical dimensions - 1D, 2D, 3D
  6. What visual que's  are used to represent information - color, line patterns, fill area, animation

more to be added to this classification list over time

I decided to clean up the first animation that I had learned from the actionscript animation book. It can also be viewed here.

In the process I made some mistakes and learned a few things:

  1. I extended the object model to be more a mathematical graph based model - with Nodes and Edges - and I tried to abstract out the concept of forces
  2. I made the mistake of trying to iterate over the springs instead of the nodes - this makes life more complex as the forces are applied to nodes - it meant that I was accidentally applying gravity to the node once per spring attached to the node - conclusion: you most iterate over the nodes and then for each node - each force applied to that node
  3. I made the mistake of trying to apply all calculations and rewdrawing the spring lines in the same loop. This does not work because particles later on in the calculation loop will change position. Conclusion is that you need to calculate all of the nodes new positions before having a separate loop with redraws the spring lines
  4. I created the concept of MoorPoint nodes - nodes which do not move in response to forces - only the user's mouse drag and drop actions

The code can be downloaded from here.

After doing all this work - I found that the system was unstable - in terms of a small change in spring value or gravity could result in the nodes disappearing off stage. You can add damping or change the values but I decided to look at some libraries. I downloaded this as3 visualisation library - which is fantastic. They have done a great job of creating a great object orientated model that can be applied. For example they

  • have nodes and edges
  • have separated out the spring, attraction and gravitational forces into implementation of an iforce interface
  • the forces are applied to particles - ie. not to nodes - so the concepts of particle forces and a node-edge graph are kept separate
  • they have rapid node and edge iterators
  • they have the concepts of a fix() attribute that prevents the node from moving when subjected to forces - similar to a MoorPoint
  • node and edge meta data is catered for

Anyone who is working with graphs (node - edges) in no matter what language should look at the flare visualisation library

web graphCame across Barrett Lyon and the opte project - seems kind of interesting

especially the techniques of creating large graphs of the webs connectivity

"Lyon's work tracking Russian Denial of service attack extortion groups has been featured around the globe[4]. He provided details and helped coordinate with multinational law enforcement groups which resulted in the capture of Ivan Maksakov, Alexander Petrov, and Denis Stepanov [5]. The three men were at the heart of an extortion ring which was extorting money from banks, Internet casinos, and other web based businesses. Reported damages caused by Maksakov, Petrov, and Stenanov range in the the tens of millions of dollars. On October 8th 2007, Maksakov, Petrov, Stenanov were found guilty and sentenced to eight years in prison in the Russian Federation with a 100,000 ruble penalty[6]."

Next Page »