Monday 31 August 2009

Flex, Blaze DS and GAE

I’ve spent a fair bit of the long bank holiday weekend trying to get Blaze DS installed on Google App Engine but frustratingly I’ve not managed it so far.

I was working off this blog post but when I tried to create a flex project it would not validate the Blaze DS server. I think it is something to do with the flex context root that  he is using in the example. When the validator tries to do a test on that context it doesn’t work.

I’ll have another go next time I have some time. It’s annoying when you can’t get these things to work.

Other than that I am very impressed with GAE – the eclipse plug-in is really easy to set up and use. It builds a sample site with web kit and a server call for you which works as soon as launch it.

I really hope I can get it playing nicely with Flex.

FlexUnit 4 Beta 2

A new version of FLexUnit has been released as blogged about here.

The biggest improvements on the old version is a really easy to use FlexUnit ant task to run your tests as part of your CI build.

There were a couple of teething problems with the first version that they released.
The first issue was resolved very quickly with a new release within 24 hours or so of the first release.
I managed to get round the second issue by tweaking and re-building the ant task so that it would work on 2003 server. This fix may now be in the trunk build but I haven’t checked.

There is still a bit of an issue with setting up a trusted swf so that the tests can run but I understand there is a fix for this on the way.

Windows Live Writer Re-Install (again)

I’ve just had to go through another round of re-installing Live Writer and deleting any settings files that I can find.

The fix that worked last time for Live Writer not starting didn’t work this time but a re-install did.

I’ve looked for alternatives but have not been able to find anything that looks as good.

Any suggestions?

Sunday 23 August 2009

FlexBudget 0.1

I had a free weekend this weekend and actually stayed at home for the first time in ages. In between reminiscing about last weekend in Germany by racing the Nurburgring on my xBox 360 I spent quite a bit of time working on FlexBudget.

I have now basically got all the domain classes finished and all the tests written. This was true TDD – I didn’t even create any view components until 99% of the domain and tests had been written. I also wrote the tests first, checked that they failed then implemented the functionality. I did come across a bug with FlexUnit 4 doing this – sometimes if a test fails FlexUnit seems to not fail it and just say that 44/45 tests completed which was a bit weird.

You can see how far I have got here:

http://giles.roadnight.name/flex/FlexBudget/FlexBudget.html

90% of the work so far has been on the domain classes and not very much on presentation logic or views. The next step will be improve the user experience a lot – I’ll move all the new Account / Deposit etc windows into popups. There is no form validation at the moment either, just catching of events so I need to work on that.

The selected transaction panel was thrown together in about 30 mins after I had completed the rest as I wanted to play with it. This is what the app is about really – being able to tweak spending to see how it affects your overall budget. This component is pretty buggy and will throw RTEs if you click in the wrong place in the grid.

The view is not pretty, not well laid out and probably has some bugs in but I am pretty pleased with progress so far. Obviously the app is useless without what you enter being persisted in a database somewhere but that will come next after I have tidied the view up.

Try the following for an example of the functionality.

  • Create a new account called House with a balance of £500 and a date of the 1st (make up an account number)
  • Add the following withdrawals (amount, date, description, code):
    100, 10th, Gas Bill, DD
    75, 15th, Electric Bill, DD
    1000, 15th, Rent, SO
    200, 20th, Council Tax, DD
  • Add another account called personal with a balance of £100 and a date of the 1st (make up a number)
  • add a deposit of £2000 to personal on the 10th – Wages / CHAPS
  • Add a Transfer from personal to home on the 14th of £1000
  • Add a withdrawal to personal on the 2nd for £200 called Night Out with code ATM
  • Click on the night out transaction in the grid and change the date to the 11th (in the Selected Transaction Panel )
  • Click on Gas Bill and change the amount to –50

Eventually you’ll be able to drag transactions around to a new date and amounts etc will be editable in the grid.

I’m looking forward to getting this into a useable state so I can stop using a spreadsheet!

Any comments or ideas for features please let me know.

Saturday 22 August 2009

Windows Live Writer working again

For the last few weeks whenever I have tried to start Windows Live Writer on my desktop it just crashes straight away. I tried repairing it, uninstalling it, re-installing it, looking at log files and so on and so on and nothing worked.

Today however I found this blog post:

http://jcheng.wordpress.com/2009/02/08/windows-live-writer-2009-wont-start/

and deleting the files in the mentioned directory worked.

That’ll save me a bit of time as I was considering writing my own blog client in Air!

Sunday 9 August 2009

FlexBudget

I’ve spent quite a bit of time this weekend working on FlexBudget. I am pretty pleased with my progress.

I haven’t created a single view component yet b8t have just been working on the domain classes and tests.

For this sort of project TDD really comes into it’s own. As I say, I haven’t created a single view component yet but when I get to that stage I can be fairly sure that all of the domain classes will work fine – including all binding.

So far I have created the following domain Classes:

  • Account
  • AccountAdjustment
  • Transaction
  • Balance
  • Withdrawal
  • Deposit
  • Transfer

Balance, Withdrawal, Deposit and Transfer are all Transactions. Each Transaction has at least one AccountAdjustment which is associated with one account. A withdrawal has one AccountAdjustment – a withdrawal with a negative amount. A Transfer has 2 account adjustments, a withdrawal from one account and a deposit in another account.

Each account has a collection of account adjustments that are sorted by date. The balance of the account is calculated by each adjustment being passed the balance of the previous adjustment and then working out the new value.

There is quite a lot of testing to make sure that if you update the amount or date of an account adjustment the amount property on the associated transaction updates (and the binding fires) and if there are any other adjustments for that transaction that the amount updates there as well.

The next step is to create a Budget class that will hold a collection of Transactions and a Collection of Accounts. The accounts will be used to generate an array of DataGridColumns and the transactions will be used as a dataprovider.

Observe / ObserveValue

I don’t know what is happening with blogs.adobe.com but a lot of pages seem to be down or missing. I can’t find anywhere to download Paul Williams’s Observe tag and Alex Uhlmann’s blog about it seems to be down as well.

I’ve uploaded them here so if you’re wanting them grab ‘em quick.

I worked with Paul and Alex on my last project at Morgan Stanley. Both are very talented developers and good fun to work with.

Saturday 8 August 2009

EventListener

This is a little class I wrote that make it a bit easier creating and removing event listeners.

If you have ever written code like this:

public function set model( value : myPM ) : void
{
if( _model )
{
_model.removeEventListener(
"someEventType",
myFunction );
}

_model = value;

if( _model )
{
_model.addEventListener(
"someEventType",
myFunction );
}
}

Then EventListener should make your life a bit easier. The above code in MXML would become:

[Bindable]
public var model : MyPM;

]]>

target="{ model }"
type="someEventType"
handler="{ myFunction }"
/>

And in an as file:

private var domainListener : EventListener = new EventListener(
null,
DemoDomain.SAMPLE_DOMAIN_EVENT,
domainHasDoneSomething );

public function set demoDomain( value : DemoDomain ) : void
{
domainListener.target = value;

_demoDomain = value;
}

I think it makes your code look a bit nicer – especially in mxml files where you can just declare the event listener and use bindings.

There is also a passEvent property that determines if the event is passed to the handler function.

I’ve put a demo of it in use here with view source enabled and a download of the source code. This demonstrates an event listener with a target of a domain model. You can then inject the domain model into the PM, the PM then dispatches an event when it receives an event form the domain. IF you remove the domain from the PM the event listener is the cleaned up and the PM no longer dispatches events.

Let me know if you find it useful.

Flex Formatter Eclipse Plug In

At work recently I’ve been using a Flex Formatter eclipse plug in. It’s REALLY useful and saves so much time.

Take a look here.

Saturday 1 August 2009

Parsley 2.0

On my last 2 projects I have been using Parsley 2.0. An IOC framework for Flex.

It is an alternative to Cairngorm and does a lot more on top. I have used Cairngorm for a long time and did like it but when you get used to Parsley you really start to appreciate the benefits.

Tom Sugden who I worked with on my last project has written a good blog post about IOC in general here and has some specifics about parsley.

I’ve implemented a sample project that demonstrates dependency injection, managed events and modules. The sample is here and a zip of the project is here. This is a Flex 4 project so you’ll need to download Parsley from SVN and patch it.

The sample project has 2 views in the root with a different instance of the same PM injected into them. The PMs both have the same global domain object injected into them that has a string in. This string is displayed in the text area and you can see that any changes are reflected in both views.

You can also load Module 1 and then load Module 2 inside Module 1. Parsley creates a child context for each of these modules but messages still flow to and from the modules as does the injecting of the global domain object.

The area at the bottom of the screen is a custom log target that displays logs from parsley so we can see what’s going on.

If you want to find out more about parsley the spice factory home page is here. There is some great documentation and a really good forum with excellent support from the creator Jans Halm.