Introduction to RestfulX
Although I still wrote two posts about that (a screencast and a tutorial), this article is the first of a series of articles I pretend to write about RestfulX, an incredible framework to integrate Flex (or AIR) with RubyOnRails, Google App Engine, CouchDB, SQLite or even with Juggernaut (a Rails plugin to push messages from the server to the client). In the very first posts I’ll focus on the integration between Flex and Rails. This will be a kind of “conceptual” post, but is as important as the “practical” ones.
The main idea behind RestfulX is to bring to Flex some of the development principles of rails, using a REST based communication. For example, if we define a model named Project that has many Tasks, we could do this on the Rails side:
@project = Project.new @task = Task.new @task.project = @project @project.tasks.size # The result is 1
And the RestfulX framework brings all these concepts to Flex (through ActionScript):
var proj:Project = new Project; var task:Task = new Task; task.project = proj; proj.tasks.length; // The result is 1
About the framework
RestfulX was first created under the name of Ruboss and it was a proprietary framework. Some time later it becomes free and open source. Today it is maintained by one of its creators, Dima Berastau.
The RestfulX have two main projects, kept in GitHub: one is restfulx and the other is restfulx_framework.
The first (restfulx) is the code generator, built in Ruby. When this project is compiled we have the gem that is installed when we run the gem install restfulx command.
The other one(restfulx_framework) is the library code (swc) downloaded into the lib folder when we first run script/generate rx_config. This library contains all the classes responsible for the serialization and de-serialization of all requisitions between the client and the server.
An important concept to keep in mind when programming with Restfulx is the it was created to download the model’s data as the user needs them. This way, when the user needs some information the framework try to hit the server, download all the necessary information and keep it into its cache. From this moment on, when the downloaded data needs to be accessed again, the RestfulX uses the cached version, instead of asking the server again. Then the use of the cache reduces the responsiveness of your application and the user feels happier! Clear, if the programmer wants to reload the cached data, it is also possible.
The communication between the client and the server can be made using XML or JSON. Looking the most recent Dima’s teets, it seems that he is planning to deploy RestfulX with support to AMF, what will made the communication between client and server to be much faster.
Because it is easy to work with the data on the database, the programmer will have much more time to work with the design of the application and the interaction with the user. If he master Flex, Ruby, Rails, and RestfulX, he will spend a little time to build a fantastic aplication!
These are the main concepts about RestfulX. Many things will be much clear when the next posts are done.
To know how to create and configure a new project using RestfulX, see my screencast (in pt-BR) or the Dima’s one (in en).
Até a próxima!
Poderia avaliar este artigo, por favor? |
