dombroskib
30 Apr 2009, 4:23 AM
I don't want to seem like a naysayer, but I am perplexed at the interest or desire to use or develop Ext.Direct. RPC methodologies have come and gone in the past (COBRA, RPC Web methods, etc) and most have fallen to the side of mainstreet development practises for contract driven development. IMHO RPC lends itself to a wild wild west type of development. Where does security get applied? Logging? Auditing? Standards? How scalable is it?
With a little thought and planning the 'ease' that developers are looking to gain from Ext.Direct can be achieved in the previous versions of Ext without coupling the client side code directly to server side code.
After several projects with Ext we have refactored and settled in on a recent project with the following goals
- A single entry point to all JSON calls into the middleware. This will allow us to control, process and append new requirements at the message level in the future without going and touching code in xxx methods. Once alll the preprocessing is done the entry point will route the request to the correct business object. Once the business object is done, the entry point will apply post processing logic (auditing, logging, etc) and returns to the caller.
- To accommodate the first requirement a common AJAX request signature is needed...we ended up with Format (JSON or XML), Domain, Message, Version, object. Domain is not a web domain, it is a Business Domain, for example Membership. An example of a message in the Membership domain would be "CancelMembership" and the version "1.0"
- Client side rendering restricts application features based upon authorizations, BUT server side security must also apply restrictions based upon the same authorizations...after all we really don't trust what comes from the web. This is easy to implement because we have our single entry point and every request will have a Domain and Message that we can apply authorizations against. This is implemented in a authorization preprocessor.
- Server side developers will NOT need to configure xml files or modify code to get their method to process a request, instead they simply have to decorate methods and classes with attributes and that alone will have their class/method participate in the message processing.
Since we all love code, here is some sample code of what we ended up with. We are a MSFT shop and have c# code, but the patterns can be implemented in any backend OO language. It has definitelt increased our productivity as there is little to do to implement a new message/business logic.
The below code is how the server side developer decorates their method with attributes
[MessageProcessorRegistration("Membership","CreateAccount","1.0")]
publicvoid AddAccount(MessageRequestContext ctx)
{
}
The below code is how the server side developer return their message results
[MessageProcessorRegistration("Membership","CreateAccount","1.0", )]
public void AddAccount(MessageRequestContext ctx)
{
...
ctx.Response = objectReturnedWithID;
}
The below code snippet is how the client side developer would make a JSON/AJAX call, the key is everyone uses the RodomRuntime.ProcessRequest
this.AddMember= function() {
var member = //Build some type of new member object here
RodomRuntime.ProcessRequest("JSON", "Membership", "CreateAccount", "1.0", member, this.ProcessAddMemberResults, this.AddMemberFailure);
}
Ok, so you are asking how is this better?
KISS! It is very SIMPLE. All the pieces and parts are already in Ext, we just needed to apply a few simple well proven design patterns.
Maintainable and Extendable
We are now in the process of extending the server side method attributes to include Cacheability. If a method has cacheability set we will first call out to memcache to see if a ctx.Reponse already exists. The cacheability attributes control who, how and when something is cacheable.
We have added a new preprocessor for scability that allows us to direct the request off to a MOM hub (we are using ActiveMQ) that allows us to scale the request processing to as a large of a scale as the back end datastore will support.
To reduce the number of client/server roundtrips we are looking at the ability to submit and process multiple messages in a single request from the client (think mashup and application startup time).
We can support new versions of the same message for backwards compatability.
Wow, I just hit preview, and this is a long rant. I guess what it comes down to is that Ext.Direct, although nice, I don't think it really fits into a usable enterprise feature. Anyone else have the same thoughts or am I missing the point completely?
With a little thought and planning the 'ease' that developers are looking to gain from Ext.Direct can be achieved in the previous versions of Ext without coupling the client side code directly to server side code.
After several projects with Ext we have refactored and settled in on a recent project with the following goals
- A single entry point to all JSON calls into the middleware. This will allow us to control, process and append new requirements at the message level in the future without going and touching code in xxx methods. Once alll the preprocessing is done the entry point will route the request to the correct business object. Once the business object is done, the entry point will apply post processing logic (auditing, logging, etc) and returns to the caller.
- To accommodate the first requirement a common AJAX request signature is needed...we ended up with Format (JSON or XML), Domain, Message, Version, object. Domain is not a web domain, it is a Business Domain, for example Membership. An example of a message in the Membership domain would be "CancelMembership" and the version "1.0"
- Client side rendering restricts application features based upon authorizations, BUT server side security must also apply restrictions based upon the same authorizations...after all we really don't trust what comes from the web. This is easy to implement because we have our single entry point and every request will have a Domain and Message that we can apply authorizations against. This is implemented in a authorization preprocessor.
- Server side developers will NOT need to configure xml files or modify code to get their method to process a request, instead they simply have to decorate methods and classes with attributes and that alone will have their class/method participate in the message processing.
Since we all love code, here is some sample code of what we ended up with. We are a MSFT shop and have c# code, but the patterns can be implemented in any backend OO language. It has definitelt increased our productivity as there is little to do to implement a new message/business logic.
The below code is how the server side developer decorates their method with attributes
[MessageProcessorRegistration("Membership","CreateAccount","1.0")]
publicvoid AddAccount(MessageRequestContext ctx)
{
}
The below code is how the server side developer return their message results
[MessageProcessorRegistration("Membership","CreateAccount","1.0", )]
public void AddAccount(MessageRequestContext ctx)
{
...
ctx.Response = objectReturnedWithID;
}
The below code snippet is how the client side developer would make a JSON/AJAX call, the key is everyone uses the RodomRuntime.ProcessRequest
this.AddMember= function() {
var member = //Build some type of new member object here
RodomRuntime.ProcessRequest("JSON", "Membership", "CreateAccount", "1.0", member, this.ProcessAddMemberResults, this.AddMemberFailure);
}
Ok, so you are asking how is this better?
KISS! It is very SIMPLE. All the pieces and parts are already in Ext, we just needed to apply a few simple well proven design patterns.
Maintainable and Extendable
We are now in the process of extending the server side method attributes to include Cacheability. If a method has cacheability set we will first call out to memcache to see if a ctx.Reponse already exists. The cacheability attributes control who, how and when something is cacheable.
We have added a new preprocessor for scability that allows us to direct the request off to a MOM hub (we are using ActiveMQ) that allows us to scale the request processing to as a large of a scale as the back end datastore will support.
To reduce the number of client/server roundtrips we are looking at the ability to submit and process multiple messages in a single request from the client (think mashup and application startup time).
We can support new versions of the same message for backwards compatability.
Wow, I just hit preview, and this is a long rant. I guess what it comes down to is that Ext.Direct, although nice, I don't think it really fits into a usable enterprise feature. Anyone else have the same thoughts or am I missing the point completely?