Jai’s Weblog – Tech, Security & Fun…

Tech, Security & Fun…

  • Jaibeer Malik

    Jaibeer Malik
  • View Jaibeer Malik's profile on LinkedIn
  • Subscribe

  • Feedburner

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 29 other followers

  • Archives

  • Categories

  • Stats

    • 379,210
  • Live Traffic

Flex: Choosing the right flex data transfer strategy and designing the application accordingly

Posted by Jai on August 27, 2009

This post covers the different strategies you can use for data transfer for the flex applications and designing the application accordingly. We will have a look at the different influencing factors while deciding the data transfer strategy which can be Data Transfer Objects, some client based facade on the server side  or may be some adapter like dphibernate based on application specific requirements.

This is part of the series of posts:

Flex then, now & tomorrow – From a java developer’s perspective
Flex: Cairngorm (MVC), SpringActionscript (IOC) and other Cairngorm Extensions
Flex: SpringActionscript (IOC) & SpringActionscript Cairngorm Extension Sample Code Examples
Flex: Cairngorm View Notifications Strategies, Responders from Command to View
Flex Tips&Tricks

to cover different strategies in flex development using Cairngorm framework to solve different practical problems.

Influencing Factors for Data Transfer Strategy

Before deciding on any strategy that how would you architect your application, give it at least some consideration that what your application is trying to do. Try to figure out the influencing factors which will affect the behavior and response of your application.

Few of the influencing factors before considering the data transfer strategy are like:

  • data intensive
  • transfer over wire, network bandwidth
  • static data centric
  • media centric
  • user experience centric, fancy look and feel

Having the performance related bottlenecks in the application is very common in many applications. To optimize in terms of performance from the first day is not mandatory but to have an overall idea that what you are developing and how the current implementation will effect the bigger picture, will always help you in the long term.

You should do the profiling and performance optimization with some stable release only but keeping a tap on it on regular basis will minimize the rework and help you in designing the application in better way.

Analyze whether the application is more data intensive which means you don’t want huge data transfer over wire. And if there is no bandwidth issues and application will only be used internally then you don’t want to complicate the design in terms of data transfer strategy, you may end up solving a problem when there is actually no problem.

If you have lot of static data being used in the application, plan how you would manage and keep the assets in the application structure.

Lets say you have some kind of data intensive enterprise application where you have your flex client which uses remote objects to get data from server where you have flex BlazeDS, spring, jpa and hibernate etc. on the server. And just to add to the problem, you may also have another client like web services which is also using the same server in the back end. Now what are the different options you have and accordingly can plan the strategy for transferring the data for these clients.

Data Transfer Object (DTO/VO) Strategy:

You can create value objects on flex side mapping to the remote classes which are domain entities and use only the only which are directly used on the client side instead of copy pasting all the fields in the value objects.


import com.adobe.cairngorm.vo.IValueObject;
    [RemoteClass(alias="com.test.model.User")]
    [Bindable]
	public class UserVO implements IValueObject
	{
		public var id : Number;

		public var login : String;

		public var firstName : String;

		public var lastName : String;
...
...
}

You can use separate Data transfer objects rather than the actual domain entities to transfer the data over wire.

Consider a case where you have some big selection list and you only need to capture the user actions. You can transfer the whole object data on client side and then create the list view based on that only if you don’t have any network bandwidth issues and data is sufficient to get stored on client. But what if there is whose amount of data involved, you would like to explore the option to create the data objects on server side containing the enough information to be displayed on the client side and capture the selection and return back the list of updated objects back.

Few of simple examples I can think of can be the search request parameters and search results etc. where you just would like to pass the required data. Another example can be a huge list of check box selection etc. where you just need to capture the user selection and update the back end system accordingly, you would like to consider creating separate data transfer objects with check box label and unique identifier information.

Flex-Facade/Web-Services-Interface Strategy

Few points worth mentioning and that you can take care while designing the application:

  • client specific operations
  • performance optimization strategies
  • to solve lazy loading problems in case using hibernate
  • data transfer object conversion implementation
  • minimum changes to domain entities and back end services to keep it scalable for other kind of clients.

Depending on the different types of client you can have like flex and web services calling the same services, you would like to architect your application so that the back end services are independent of the calling client.

There may be cases where you need to do some client specific operations on server side to cater the problems of performance optimization and few other strategies, which is applicable to both flex and web services.

In such cases you would like to have separate interfaces for the clients. Lets say you can have separate flex client facade on server side which will cater the requirements to do flex client specific operations on server side. You can also use this to plan the data transfer strategy for flex client and this facade can also store the conversion factory implementation which will convert the value objects to the domain entities.

If you are using spring BlazeDS for flex remoting, the data transformation layer will try to load all the connected objects while transferring it over the wire and you may face the lazy loading problems very often.

Similarly, you can control the services exposed via web services by having separate interface for web-services with out changes the common back end common services.

Flex Hibernate Adapter framework, dphibernate Strategy

Another solution you would like to have a look is the dphibernate and to get started.

“dpHibernate is a custom Flex Library and a custom BlazeDS Hibernate adapter that work together to give you support for lazy loading of hibernate objects from inside your flex applications. “

Depending on the application requirement, in case it is not very data intensive and there are no network bandwidth issues, you can directly use this to solve the lazy loading problems and can avoid the intermediate processing.

This framework is still not very stable and is work in progress. But give it a try and explore further.

The other thing to think of is that you would have to implement this adapter specific interfaces on both the client side and server side. If you application is only for flex client you can think of it or may be you can implement this strategy inside the flex-facade to do the conversions.

I hope this will give you some idea to plan the data transfer strategy in the application and depending on your requirements you adopt the right one or may be mix of these.

Next–>Stay tuned for the post on security implementation on flex client side based on permissions filtering.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: