Monday, December 21, 2009

Merry Christmas

Dear Readers

I wish you and your beloved ones a merry christmas and a happy new year.
I hope 2010 will be as exciting and wonderful as 2009.

See you next year,

PS. My unplugged christmas greetings

Tuesday, December 15, 2009

Browser back button vs RIA

Very often we hear, that RIA applications break the conventions that the users are accustomed to in the browser, especially the use of the back and forward button.
I wonder if people really expect that though. Aren't RIAs more like real applications than a webpage? When was the last time you missed the back button in Adobe Photoshop, MS Word or some similar app?

Also, when it comes to implementation, there are some really hairy situations. Say you have a screen with a form, the user fills in a few things and presses the back button. Your common policy is to display a alert asking the user, if she really wants to navigate away. Now imagine the user says no, what does that do to your history? The history thinks, you have been going back, while in fact you stayed on the same page.
Allthough, now that i think about it, probably i can forward the history to undo the back button action. Need to test that. Thanks for listening :)

Flex & Iframes - oh my

Ok, so we have this nice little Flex app, which allows the user to use the browser back button. Wohoo, usability galore! But what if we have a iframe opened to show some html on top of the Flex app and the user presses the back button. Now it gets nasty, sniff. My beautiful code needs to do something real now :)

Tuesday, December 8, 2009

FlexBuilder locale editing conflics with Java

We are working on a international project and need some international characters inside of the locale .properties files. However, whenever we edit a properties file and save it, it gets converted to ISO-8851-1, allthough the workspace is set to UTF-8.

We are using the plugin version of FB as we also need to edit Java files. I found out, that in Window/Preferences/General/ContentType the encoding for properties files is set to ISO. After some research i found, that Java needs the .properties files to be in ISO. So i think there is a conflict here. JDT wants to ensure, that properties files are in ISO, while FB needs them in UTF-8.

Our current solution is to use Notepad to edit the locale files.
In the long run it might be better though, to change the ending of the locale files to something else to avoid this conflict.

Please vote for this bug:

Friday, December 4, 2009

FlexUnit extended for long method names

Today i extended FlexUnit a bit, so we can see long methodNames. When we try to follow the BDD schema "Given A When B Then C" the names can get really long. Here is one example, and it is not even the longest one.


However, long methodNames are truncated in the right panel of FlexUnit. So your beautiful methodName ends up looking like:


Not very helpful. So the first thing i did, was to replace the mx:Label with a mx:Text to allow for multiple lines. But to take it a little bit further, i also reformatted the methodName. Underscores are replaced by newlines and the came case text is broken up into words. So in the end it looks like this

When Transactions Are Loaded
Then Transactions Are Sorted By Date Descending

Much better!
Some things don't fit well in this schema though, eg single character words like "a" or interface names like ISomething. But still, the overall result is much more readable than it was before. The screenshot below shows what it looks like in FlexUnit.

I have added a entry to the bug base for flex unit. Please vote for it, if you want to support it:

Tuesday, December 1, 2009

Micro modules anyone?

At the moment i follow this interesting blog series about modularizing applications. Also I'm playing around with FunFx and Cucumber for functional testing flex applications.
One problem with functional testing is to navigate to the view you want to test. Maybe you need to login first and click a few menu items before you get to it. What if something changes in these areas. It might break all you functional tests for a otherwise unrelated view. I think it would make sense to create applications containing this one view only, so you don't need to navigate to get there. Now what if this view was in a module of its own? This way it could be used in the tests and in the app.

I wonder if somebody has experience in building Flex apps from such micro modules, ie. Modules which contain a very small part of the application?

Profiling remoting calls

For our app i needed to measure the duration of backend calls. Luckily our delegates were all subclassing the same AbstractRemoteDelegate. So it was quite easy to add something in. What i did is to create a Responder which measures the duration of the calls and writes them to a Log. Inside the AbstractRemoteDelegate i add this responder to every call. This gives me the data. A DataGrid inside a TitleWindow is used to display the data.

In general instrumenting a application for debugging/profiling is a interesting topic. What are you using?

Monday, November 30, 2009

FunFx: Flex Gui Testing

I'm playing around with FunFx atm. It is based on the automation packages, that come with FB professional. It is quite interesting to see, how components are recognized by the automation package.
For example: My form contains a FormItem with a label "username" and a TextInput with a id/automationName "username". When i tried to access the TextInput i got an error, because the automation package was returning the FormItem instead. It took me a while to find out, that i had to give the FormItem a automationName other than "username" to make it work.

Sunday, November 29, 2009

Conditional compilation considered harmless, not.

Just recently i discovered a little problem with conditional compilation. Our dev build was working fine, while our test build had a unexpected error. It turned out, that the error was in a part of code which was included by conditional compilation. So, when you test your classes, you have to make sure that all the different branches are tested.

Wednesday, November 25, 2009

Embedding Fonts Compiler Issue

The guys at developmentarc have a good article about font embedding online. Probably most of the old time flashers know this already, but still it is nice to have it written up nicely.
In my current project we were trying to do the same. Unfortunately it didn't work.

Enter the magic land of font formats. It turned out, that the fonts were not recognized as bold or italic fonts, even though they were bold or italic fonts actually. The problem was, that the font's internal header didn't have the style flags for bold/italic set. According to the fontshop this was to avoid compatibility problems. So what we had to do, is to open the font in a font editor and set the flags accordingly. After it was working fine.

Nice hack. However, i think it is a symptom of a more fundamental problem.
Flash/Flex uses the styles like bold/italic for two different things. First for telling the compiler which style to embed and second to define, which style the font is supposed to be used for.

Imagine you want to use font A as the normal font and font B as the bold font. However font B is not bold and so the internal font header flag for bold is not set.
Basically this is the same situation as decribed above. You would have to fiddle with the font header again.

The best solution would be to change the compiler really. We should have one flag to tell the compiler which font/style to embed and another flag to tell it, which style this font should be used for.

Feel free to vote and add comments to the feature request in Adobe's bug base:

Tuesday, November 24, 2009

Keep your presentation models small

It is tempting to use a presentation model in multiple views. However, this increases the size of the PM. Also it makes it hard to understand.
If you need to share state between two views/pms it might be better to inject a model object into both pms instead.
One example i'm currently working on is the loaded-state of a module. In the module loader i want to update this state and in some other view i want to check it and react accordingly. Instead of having a simple Boolean on a PM and sharing the PM, i'd prefer to create a model object and share it between two independent PMs.

Monday, November 23, 2009

Best practive repository

This morning i read this nice blog from JD Meyer about Distributed Teams

One thing i found interesting is what he calls a "Best Practices Repository"

Best Practices Repository. We store our best practices for each project in a project-level repository. At the end of the project, we port the best practices to a shared repository across projects. This way each project is focused on “best practices,” and these are very specific and detailed. The all up best practices are more generalized to be useful across projects, and as a starting point for new projects.

I think this is something every project can benefit from. A repository which describes the practices which are used throughout the project.

Saturday, November 21, 2009

Friday, November 20, 2009

Nice article: Flex component lifecylce

Use interfaces for your injected models to ease testing

We use IoC to inject our models into the presentation models. When we test a presentation model we inject the models manually in the setUp method. Some models need things to be injected as well. This can make the setup quite complicated. To avoid this complexity it is very helpful if your model properties are typed as interfaces, e.g.

public var myModel : ISomeModel;

This gives you the possibility to replace the model with your own mock implementation of the interface. Typically your mock implementation does not use nested models. So the setUp of this mock model is much easier than setting up the original. This is especially true if you need to inject things, which are unrelated to your test, but are needed by the original model to work at all.

Thursday, November 19, 2009

RIA Design Patterns: NavigationModelAdapter

In our current application we use a nice design pattern for controlling the views. I call it NavigationModelAdapter.

We have a central NavigationModel, which contains a url property, e.g. /main/sub/subsub. Every part of the url controls a viewstack or a state. The navigatable views have a instance of a NavigationModelAdapter. Whenever the NavigationModel changes, the NavigationModelAdapters synchronize their view with the NavigationModel. Nice and clean.

Keep your presentation models small

Large classes are harder to read, harder to test and harder to maintain. Especially PresentationModels can easily get of hand and grow very large.

Components to rescue! One way to make them smaller is to split off a sub component from your view and create a specific PresentationModel just for this part.

What Cairngorm-3 is about

I found a very nice and inspiring presentation, which kind of explains what Cairngorm 3 is about. It is no longer about "my framework is better than yours". It is not about conquering terms like a 800 pound gorilla. It more about how to overcome our "not invented here" syndrome and how we can get closer to solutions which benefit all of us. Have a look for yourself.

I think CG3 is level 4 while CG2 is level3.

Tuesday, November 17, 2009

Worth a read: Coders at work

Peter Seibel, the author of "Practical Common Lisp" (which is nice as well), wrote a new book "Coders at work". It is a collection of interviews with some of the top programmers in the world. Do not expect it to be a very technical book, though. The guys talk more about their careers and their general ideas about programming. Quite interesting how many people use trace/printf to debug their programs.

Monday, November 16, 2009

LCDS & Flex: Solution for "Duplicate session detected" error

In my current project we have a requirement which may seem strange, but still shouldn't be too hard to implement. However it tooks us a while to find out how to solve it.

We have a Flex client with some secured content, which can only be accessed after a login.
The testers found, that after deleting the browser cookies and login again, they could no longer access any of the secured content. All we got back from the server was a "duplicate session detected" error.

The problem is, that LCDS manages its own session. So if the http session dies and gets renewed, LCDS still hangs on to its old session. Similar to a http session, the LCDS session has a id. However the id is not stored in a cookie, but in the flash player itself. It is sent to the client after the first contact to the server. You can find it in FlexClient.getInstance().id. If you set it to null before the login, the problem is fixed, because the server assigns a new id and forgets about the old session.