InfoQ

News

Case Study: Applying Java Programming Skill to Flex

Posted by Moxie Zhang on Jan 24, 2008

Community
Java
Topics
Programming ,
Rich Internet Apps ,
Design
Tags
Flex

In an article published on Adobe Flex Developer Center, Bill Bejeck shares his experience creating components and enforcing separation of concerns with Flex, from a Java developer's perspective.

Bejeck's first impression when started using Flex was:

As a Java developer I was surprised at how familiar ActionScript 3.0 was, making the learning curve fairly flat.  Once I started using Flex, it was great to see that I could use most, if not all, of the approaches to writing software that I was used to.

In the article Bejeck is trying to create components with a mixture of inheritance and composition, and enforce separation of concerns, especially between view and business logic. His Java application development skills come in handy. As he writes:

As an experienced Java web developer, I learned over time that a JSP page should be used only for presentation.  All business logic should be in classes, and if you absolutely had to have code in your JSP page, you would wrap it up in a custom tag.

In Flex, ActionScript code can be included in a MXML file using tag, which is a similar feature of JSP page where Java code can be embedded. However, learned from working on other programming platform, Bejeck employes a practice called "code behind" where visual component is defined completely in ActionScript 3.0, and use MXML to decide how the components are visually rendered. Regarding this approach, Bejeck reminds the readers:

This is an architectural approach for building an application. If you are doing quick prototyping, there is no need to always use the "code behind" technique.

Then, Bejeck goes on describing the process in details, with code segments, on how he extended the Flex build-in visual components such as DataGrid, Panel, TextInput and Button to construct custom components and event handlers. At the end, a simple 8 lines of code MXML file is shown for rendering the UI and to demonstrate the clean UI design.

Bejeck concludes:

As you can see, by using the "code behind" approach, your code is very concise and maintainable.  As you develop more complex applications, not only would you have a palate of components, but maintenance and changes to your applications would be very manageable.

Bejeck also recommends two books in the article to readers who are interested in learning more about programming in ActionScript 3. They are

I agree by Matt Giacomini Posted Jan 24, 2008 4:14 PM
  1. Back to top

    I agree

    Jan 24, 2008 4:14 PM by Matt Giacomini

    As a Java developer that learned flex I agree with author, the learning curve was almost nothing. There are a few small thins that annoy me about Actionscript, but none of them affect my productivity, the maintainability of my code, or the quality of the final application.

    I think the author should also have mentioned the cairngorm framework for Flex. Cairngorm makes it easy for you to apply some of the most common design patterns in flex. From the point of view of a Java developer, used to using frameworks, it feels very natural.

Educational Content

Brian Marick on 4 Challenges and 5 Guiding Values of Agile Software Development

Brian Marick takes us through a quick tour of the most important values and challenges to adopting Agile successfully (they aren't the typical challenges and values we hear in the community).

Are You a Software Architect?

The line between development and architecture is tricky. Does it exist at all? Is an ivory tower actually needed? There's a balance in the middle, but how do you move from developer to architect?

Agile – A Way of Life and Pragmatic Use of Authority

The word 'authority' sometimes produces an allergic response in hard-line agilists. Freedom and authority – both are bad if misused and both are good if used in right spirit for a noble cause.

Getting Started with Grails, Second Edition

"Getting Started with Grails" brings you up to speed on this modern web framework. Companies as varied as LinkedIn, Wired, and Taco Bell are all using Grails. Are you ready to get started as well?

Using ITIL V3 as a Foundation for SOA Governance

Those familiar with only ITIL V2 often scoff at the thought that ITIL could serve as a governance framework for SOA. With ITIL V3, the focus of the framework shifted towards service-orientation.

Adrian Colyer on AspectJ, tc Server and dm Server

SpringSource CTO Adrian Colyer discusses AspectJ, SpringSource's dm Server and tc Server products, OSGi and Scrum.

Adam Wiggins on Heroku

Heroku's Adam Wiggins talks about Rails, Background Jobs, Add-Ons, Ruby, and how Heroku manages to work around Ruby's inefficiencies using Erlang and other languages.

SOA as an Architectural Pattern: Best Practices in Software Architecture

For Grady Booch the foundation of a good architecture is patterns, SOA being just one of many patterns. In this Second Life presentation, Booch attempts to bring more clarity on what architecture is.