Monday, January 26, 2009

Dynamic objects and the Flex profiler

In certain situations it can be handy to use dynamic objects. The advantage of dynamic objects is that you can add properties at runtime (something you can't do in Java or C#). Dynamic objects are slower than 'normal' objects but there's another problem: if it's an object of type 'Object' (for example because you wrote { id: 123 } to create a dynamic object on the fly) it doesn't show up in the profiler and therefore it's hard to track the memory used by these objects. Therefore I'd recommend to declare specific dynamic classes in bigger applications. This way you cannot only track their memory usage in the profiler but you also know which type of content is in your dynamic objects (and therefore which dynamic content is eating up your memory).

package
{
public dynamic class CustomerObject
{
}
}

Before people start flaming: this post is not a recommendation to use dynamic objects because in most cases it's better not to use dynamic objects in the first place!

Wednesday, January 21, 2009

Adobe Flex - Silverlight compiled size

I promised to provide some details on the compiled size of the application I built in Adobe Flex and Silverlight:

Flex application

Flex framework = 551 KB
Application = 279 KB
Total = 830 KB

Silverlight

XAP file = 994 KB
--> application DLL + AppManifest.xaml = 85 KB (compressed)
--> Silverlight framework = 348 KB (compressed)
--> Telerik controls used = 560 KB (compressed)

Some remarks:

The Telerik controls cause the Silverlight application to be bigger than the Flex application. I had to use them however given the bugs in the Silverlight combobox and popup controls.

The Flex framework makes a big part of the Flex application. It's however important to note that it can be cached cross domain and therefore doesn't need to be downloaded again after clearing the browser cache. In case of Silverlight each new deploy of the application requires the Silverlight framework as well as the 3rd party controls to be re-deployed.

Tuesday, January 20, 2009

Size Matters (when comparing Adobe Flex and Silverlight)

I've been developing an administrative application the last couple of weeks. I actually developed it twice: the first version was done using Adobe Flex, the second version was done using Microsoft Silverlight.

Because Silverlight was new to me (I know, use and love .NET however for server side development) I couldn't compare development time. Therefore I decided to compare the size of a number of application files.

Some value object class

Adobe Flex: 19 lines
Microsoft Silverlight: 164 lines

Main reason for the difference: Adobe Flex has a [Bindable] attribute

Some data entry screen (without datagrid)

Adobe Flex: 61 lines of MXML + 25 lines of Actionscript
Microsoft Silverlight: 108 lines of XAML + 53 lines of C#

Main reasons for the difference: Form layouting and field validation is better in Adobe Flex

Some data entry screen (with datagrid)

Adobe Flex: 170 lines of MXML + 198 lines of Actionscript
Microsoft Silverlight: 261 lines of XAML + 315 lines of C#

Main reasons for the difference: Form layouting and binding is better in Adobe Flex


My conclusion: it takes 1.5 to 2 times more lines (and in reality therefore hours) to develop an application using Microsoft Silverlight compared to developing the same application using Adobe Flex.