3D, , , " />

FlashPlatformist
Articles, Information, News, & Tutorials for Adobe Flash Platform Developers and Architects

3D UI Development – The Bleeding Edge of RIA

I’ve recently been learning a few new programs, particularly Cinema 4D and Swift 3D, in tandem with Apple Motion and Adobe After Effects CS4. I was already a pretty crafty dude with After Effects, but I had never even tapped into a fraction of what it was capable of since there is a bit of a learning curve there.

The thought came to me today as to why I have spent so much time on 3D with ActionScript when doing 3D with these tools is so much easier? My next thought was of course, the obvious answer…These 3D movies I’m making using far superior tools (for 3D design) are static in nature. These movies are quite cool to watch and fun to make, but they lack the 2 things that make ActionScript 3D so intriguing: 1) user interactivity (the thing that makes games so addicting for the “gamer” community), and 2) the ability to make the content dynamically driven by data on a server hundreds or thousands of miles away.

There are a few “blocking points” though that we developers who consider ourselves “the bleeding edge of RIA” still need to address. First, although Flash 10 has undergone substantial improvement for 3D rendering, the code required to produce 3D user interfaces is still complicated and buggy, and it is still not true 3D. The vector-based image sequences deliver the illusion of 3D through the use of carefully placed masks, shadows, gradients, and the relational sizing of objects. This is an incredibly resource intensive process from a hardware standpoint. There is a reason that almost all PC games are still developed using C++, which is the fact that the language gives you direct access to the computer’s hardware and allows the application to make decisions in the way that the interface is displayed based on the hardware resources that are available to it.

By its very nature, the Flash VM is resource-intensive to begin with for the simple fact that it is a virtual machine (the advantage being portability between platforms). This should sound quite familiar to Java enterprise developers, who also sacrifice resources for the advantage of portability. In the enterprise, the answer is always simply “throw more hardware at it” if things start slowing down. In the consumer market however, we face a different predicament developing mainstream 3D interfaces in – say – Adobe AIR. The answer there is not as simple as throwing more hardware at it because A) few consumers know what to get or how to install it, B) computer and hardware vendors purposely limit the upgrade path of computers in the consumer market, and C) this is a terrible idea to begin with and the wrong way to look things. The answer should instead be a matter of making companies like Adobe find ways to make their software more efficient… For example, change the properties of AIR to compile like C++ does instead of the Flash VM. Unfortunately, this is not cost-effective for Adobe or even logical for them at this point, which puts the problem back in the developer’s hands, especially for framework creators like the PaperVision 3D team.

…just food for thought.

Possibly Related Posts:



Posted by Dan Orlando on January 31st, 2009 :: Filed under General, User Experience
Tags :: , , ,

New Enterprise Flex Development Model

This posting is in response to the comment left HERE, which I felt necessitated its own separate post and discussion. Before I start, I must first at least suggest that some research be conducted on Cairngorm, PureMVC, and Fireclay and allow yourself to draw your own conclusions with regard to how they fit into the bigger picture of your enterprise Flex or AIR project.

The first question that Jeff asks in his comment is if I can post a screenshot of a Flex directory structure of an enterprise application. My first thought was that I would make Jeff’s head spin if I did that due to the fact that every enterprise application I’ve worked on has had its own unique set of requirements, and differentiating the parts that could be considered as “standards-based” from those parts that were specific to the application (like a package titled “http” for RESTful services, for example) would not be of any assistance and would leave Jeff (and many others) right back where he started.

So instead, I drafted a diagram (figure 1) that so far seems like it could potentially be the bigger, better, faster, stronger framework for enterprise Flex development. Note that in order to address Jeff’s specific request, I made the diagram to be a sort of hybrid between a directory structure and a design pattern. This is the 50,000-foot view of the new architectural framework that I’m working on. Each rectangle represents a package or directory. Additionally, each layer is in fact it’s own library, with the exception of the Application Layer, which serves as the gateway to the application, and thus it is constructed as a standard Flex project and holds the primary MXML application file.

New Enterprise Flex Application Architecture

New Enterprise Flex Application Architecture

Notice that the different layers are completely unaware of each other. In fact, it is impossible, because if you attempt to add one of the libraries as a reference in the properties of another library, Flex Builder should throw a bunch of random “unknown errors” at you. This is because you have a cyclical redundancy in the build of the Application layer project (note that I am also addressing one of Jeff’s other points, which was to elaborate on the concept of separation of layers in the form of libraries).

In the diagram above, the application layer (which is the ONLY layer created as a Flex or AIR project, not a library project) holds references to the Business Layer, the Component Layer, and the Behavior Layer, which are all libraries and compile as separate swcs. During development however, I suggest you do not add the swcs to the libs folder of the Application Layer project, but rather add them as project references. Then, each time you build, you will notice that Flex Builder automatically recompiles each swc and adds them to the libs folder of your Application Layer project, as long as you have specified the libs folder in the “libraries” panel of the project properties. If you don’t do it this way, you will likely end up with “stale data”, meaning you’ve got an old swc from a previous build of one of your libraries, but the code in that library has been changed.

I must mention that the diagram above is merely a prototype, and has unfortunately not yet been put into practice. Therefore, I am open to feedback on it because, having been dissapointed in the past by Cairngorm and PureMVC, this is what I will be using for my next 2 enterprise level Flex development projects. At the same time however, this is only my first draft. The reason I drafted a diagram of a structure that has not yet been used in a real environment is for the simple fact that I would be doing Jeff – and everyone else that reads this – a disservice by showing you a diagram that is based on a past enterprise level project. This is because with each project, there were architectural decisions made that led to problems later. This is pretty typical when a new language is brought into the enterprise development space, and is to be expected.

The bottom line is that Flex and AIR are still very immature, and those of us who are using these technologies for enterprise development are still learning from our mistakes. Ultimately, we do our best and implement the design patterns we know, often from J2EE patterns since it bares the strongest resemblance to the Flex architecture. However, Flex (and AIR, and AS3 too for that matter) are unique in that they are event-driven. Therefore, a somewhat unique approach must still be taken to an enterprise Flex application that cater to it’s differences. This is why Cairngorm has a breaking point. Once an application becomes massive in size, a Cairngorm-based app turns into spaghetti-code and it becomes nearly impossible to track down events, event handlers, request-response handlers, etc.

Some Important Points

There are a few things I should point out about this initial draft shown above. First, it may not be immediately apparent, but it is in fact based on the MVC (model-view-controller) design pattern. The reason it is hard to tell at first glance is because we’ve got quite a few additional micro-patterns in here. For example, the “event bus” is based on the publish-subscribe design pattern, and I attribute Shashank Tiwari and his work on Fireclay for this idea. Shashank is developing Fireclay as an alternative to Cairngorm and PureMVC for many reasons, some of which I previously stated in regard to Cairngorm. The difference however, is that in the “bindingDictionaries” package – which is probably the most important to make note of in the application layer – is where the mapping of events to their respective handlers occur. This partially breaks away from how the publish-subscribe pattern is being used in Fireclay.

The relational size of the Business Layer/library in the diagram does not do justice for how large the business library will likely get in an enterprise Flex application. There is a lot of abstractions that must be made here and a significant amount of internal processing within this library. One of these abstractions I should point out is that the “model” package would contain a package within it called “vo” or “valueObjects”, which would basically hold references to all of our data as it is captured from the server.

Ultimately, there is a lot going on here and again, this is an over-simplified, high-level overview that encompasses my initial ideas for the architectural design pattern that I am working on developing right now. The important thing about it is that it resolves the many problems that I have seen come up in enterprise Flex development, whether it was a custom architecture being used or Cairngorm, or PureMVC, the problems that arise are consistent.  That is not to say however, that this is an end-all, be-all solution by any means….in fact, it is still just a baby.  However, I will soon find out where the weak points are as I continue to draw out additional diagrams to accompany this first iteration in my efforts of constructing a solid and robust architectural “best practices” standard for Flex enterprise development…well, at least for my own projects:)

Overall, I think the community is in great need of something that supercedes what is currently out there considering Flex and AIR are being used on such a grand scale all of a sudden for enterprise RIA development. I’m not sure if this is the start of something that will fulfill this need for the community, but at the very least it will give me what I need to make my future enterprise Flex projects successful.

There is one last point that Jeff makes in his comment, as follows:

“I’m struggling with the separation/inclusion architecture of these apps because most of them will have interdependencies – security, model, commands, etc.”

The answer here is to simply remove these interdependencies.  If this seems like a ridiculous and nearly impossible solution, then I might suggest that this project will be a nightmare for you until you decide on an architectural solution for this project and just accept the fact that you are going to have to hack away at the code in order to remove the interdependencies. In some cases however, interdependencies are ok. The simple rule with the solution that I have diagrammed above is that if the class doesn’t fit into any one of the 3 libraries, then it belongs in the Application Layer.

I hope this helps.

Possibly Related Posts:



Posted by Dan Orlando on January 26th, 2009 :: Filed under Enterprise Flex
Tags :: , ,

Flex and the Enterprise: Making Architectural Decisions

I currently have two very large Enterprise level Flex applications on my plate right now. The first is an overhaul of an already-existing application, where “best practices” and “design patterns” simply was an afterthought. The second application has not been built, as the company is in the process of raising financial support for it. Meanwhile however, I am in the process of creating the architectural structure for both of these. My first thought was to save some time and start with something that already exists. Here are my findings on my research:

Cairngorm

Every Flex developer has at the very least heard about Cairngorm. It is the brainchild of a company that was called Iteration Two, which was later bought out by Adobe and most of Iteration Two became the EMEA team of Adobe Consulting (This is why Adobe is constantly pushing Cairngorm down our throats).  Today Cairngorm is actively advocated by Adobe Consulting, the members of which are responsible for training Flex developers of large enterprises prior to transitioning company initiatives over to RIA. Thus, the effort to make Cairngorm the defacto standard for Enterprise Flex development is significant.

What’s Wrong with Cairngorm?

Cairngorm suffers from some inherent issues which, to me, were severe enough for me to move on, leaving Cairngorm behind. First of all, Iteration Two was a company focused primarily on J2EE development. If you are familiar with J2EE, go read the docs on Cairngorm. What you’ll find is that Cairngorm is nearly identical to the design patterns used in J2EE. While these design patterns work great for request-response Java apps and the J2EE world, some of these patterns were jammed into Cairngorm to solve certain problems, which are – in reality – a bad fit for Flex.

For example, the use of “business delegates” as they are referred in Cairngorm doesn’t completely make sense as this functionality is already handled inherently in the Flex framework. You also see a classic request-response pattern happening between the model and view layers using the Cairngorm FrontController class, similar to Java-style request-response programming between client and server. Additionally, all events must extend a central event, referred to as CairngormEvent, which is actually something that I think is a plus for Cairngorm, as this allow for a bit of organization among events. At the same time, it would have been nice if they called it “CentralEvent” and not CairngormEvent. Sometimes ego and branding get in the way of logical thinking I guess.

PureMVC

PureMVC really is exactly what it’s name implies. It is truly PURE mvc. In other words, it is so strict on the use of the MVC design pattern, that there is little room for implementation of other design patterns to solve other issues. The model-view-controller pattern is definitely the best central design pattern to use for enterprise Flex development. However, it is in no way in and of itself the end all-be all to enterprise flex apps.  This framework is also extremely dependent on the use of the Singleton design pattern, which I completely disagree with. Singletons should be used  VERY carefully, because in most cases, it’s use totally contradicts the basic principles of Object Oriented Programming.  It is for this reason that PureMVC was clearly not the answer in my quest, and so I moved on…which brought me to Fireclay.

Fireclay

Fireclay is by far the least known architectural framework for enterprise Flex development, and it is still in it’s infancy. Having been started by one  of my favorite auhors, Shashank Tiwari – whose most recent work is AdvancED Flex 3, published by Friends of ED (good read, I highly recommend it!) – the framework has not gotten much support yet from the community. I believe this is due to Fireclay being young, but also the fact that I think most people do not understand why Fireclay was born. You can currently find Fireclay up on GoogleCode here. The purpose of Fireclay, according to Tiwari, is to circumvent the inherent issues of Cairngorm and PureMVC. In order to accomplish this, it makes strong use of the publisher-subscriber design pattern. I immediately recognized Fireclay as being the closest thing to what I was looking for in an overall architecture to use for my upcoming projects.  Here are some of the notes that I took while studying Fireclay:

- It is hard not to notice the heavy use of the publisher-subscriber design pattern here…I’ve always thought of this as being a worthy alternative to having a billion events scattered throughout a massive flex app as i have seen in the past…eventually things just get out of control and some sort of event queue must be implemented.

- I like the event bus, as it has a built-in queue, which would be useful if the application state was “not ready” for example. A “not ready” state might mean that the application has not completed its initial communications with the server side that are necessary for startup.

- I like the idea of containing all services and events in a registry. This provides essential organization as the app grows.

- The event mapping methodology is interesting, and seems to allow the application to be extremely scalable. Binding tends to prevent loose coupling, and this type of “mapping” allows for enterprise developers to get away from being so heavily reliant on binding events and listeners if I am understanding this correctly.

It is evident that Fireclay is the closest thing to being worthy of the Enterprise Flex “best practices” Framework crown, but it is going to be a while before it is ready. Ultimately, it needs support from the community to complete it’s development. Additionally, there are a few things that Fireclay does not address….not yet anyway. Most importantly, it appears that it could benefit from the input of some of the advanced Flex architects in the community as it tends to overcomplicate some thing, which brings me to my last point…

Conclusion

The ultimate goal in architecting a design solution for an Enterprise level Flex application is to use the infamous K.I.S.S. theory….KEEP IT SIMPLE STUPID. However, that is also the greatest challenge for the architect…to ensure that every potential problem is addressed while still keeping everything as simple as is humanly possible so that future developers can walk in, look at a simple diagram, and know how the application works so they can start coding that same day. In essence, the architect must “see the future” so to speak and be able to predict the result of the architectural design pattern that they build and identify it’s weaknesses.

Java has 72 different frameworks, each serving a particular purpose for a specific type of application. Flex has 3 now (well, technically two and a half because Fireclay is only halfway there).  Unfortunately, it looks like I will need to develop a new methodology for enterprise Flex development because what is currently out there just doesn’t fit the needs of the applications I am responsible for right now.

Wish me luck (sigh).

Possibly Related Posts:



Posted by Dan Orlando on January 24th, 2009 :: Filed under Enterprise Flex
Tags :: , , ,

Article Released in PHP Architect Magazine

My article on working with the new Zend_AMF module, entitled “Flex, Meet Zend” was recently published in the January issue of PHP Architect magazine. Unfortunately, it looks like in order to read it, you have to purchase the PDF version of the January issue for 4.99 from their site. It’s a good article though, and if you have any interest in using the new Zend_AMF module for your client-server data communications, it is worth the 4.99 for the pdf version of the PHP Architect January issue. Anyway, here’s the link:

http://www.phparch.com

Possibly Related Posts:



Posted by Dan Orlando on January 24th, 2009 :: Filed under Announcements
Tags ::