Cool Code
Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.
The content has been bookmarked!
There was an error bookmarking this content! Please retry.
Posted by Moxie Zhang on Jan 24, 2008
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
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
Improve Java Garbage Collection, Runtime Execution, and JVM visibility with Zing
Monitor your Production Java App - includes JMX! Low Overhead - Free download
Using Drools? See what you're missing! Get the Power of Drools with the Assurance of Red Hat
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.
Kevlin Henney examines code samples to see what can be learned from them starting from the premise that one won’t write great code unless he knows how to read it.
Jason Ayers share the observations he made watching a team of developers collaborating in real time on the same code base, pushing XP, pair programming and continuous integration to their extremes.
Michael Snoyman presents Yesod, a web framework written in Haskell and containing a web server, templating, ORM, libraries (templating, gravatar, etc.).
Richard Kreuter and Kyle Banker on how to avoid classical RDBMS transactional systems by using compensation mechanisms, transactional messaging or transactional procedures.
Attila Szegedi talks about performance tuning Java and Scala programs at Twitter: how to approach GC problems, the importance of asynchronous I/O, when to use MySQL/Cassandra/Redis, and much more.
One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.
InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.
Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.
1 comment
Watch Thread Reply