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: http://bugs.adobe.com/jira/browse/SDK-24408

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"

[quote]
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.
[/quote]

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.

[Inject]
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.