Hybrid View

  1. #1
    Sencha User
    Join Date
    Mar 2009
    Posts
    31
    Vote Rating
    0
    misha is on a distinguished road

      0  

    Smile Direct or REST which is the best? :-)

    Direct or REST which is the best? :-)


    Hi guys,

    My big dilemma is whether should I use:
    1. Ext.direct and its PHP provider
    2. or Zend framework that generates appropriate REST pages for Ext.

    Is the main difference deciding whether I want my server API to be RPC or REST?

    Are there any drawbacks in using direct btw?
    Misha Peric
    Programming for web and iPhone
    www.byteout.com

  2. #2
    Ext JS Premium Member dj's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    576
    Vote Rating
    2
    dj has a spectacular aura about dj has a spectacular aura about dj has a spectacular aura about

      0  

    Default


    If your backend needs to communicate with other systems that support RESTful services then you should implement a REST interface. Besides that REST interface I would implement an Ext.Direct router that is the central place for all ExtJS communication. The benefit of having this central router is that you can batch several requests so that only one HTTP request is sent to the server. You cannot do that with directly using the REST interface of your backend but if your application makes many small requests (as it probably would if you use a REST architecture) it greatly benefits from batching requests.

    If your backend is only used with your ExtJS frontend then don't bother implement a REST interface.
    Daniel Jagszent
    dɐɳiel@ʝɐgszeɳt.de <- convert to plain ASCII to get my email address

  3. #3
    Sencha User
    Join Date
    Mar 2009
    Posts
    31
    Vote Rating
    0
    misha is on a distinguished road

      0  

    Default


    Thanx dj,

    The thing is that I would like to publish API interface of my backend for others to use too, so REST would be a bit more logical for that.

    You gave batching as main reason for using direct. But isn't batching possible with REST approach too?

    I can set autoSave to false on my restful store, and call save() by hand, so all changes to the store will be submitted in one call as opposed to multiple calls if autoSave is true, right?
    Misha Peric
    Programming for web and iPhone
    www.byteout.com

  4. #4
    Ext JS Premium Member dj's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    576
    Vote Rating
    2
    dj has a spectacular aura about dj has a spectacular aura about dj has a spectacular aura about

      0  

    Default


    Quote Originally Posted by misha View Post
    The thing is that I would like to publish API interface of my backend for others to use too, so REST would be a bit more logical for that.
    Sure, REST is widely used and as such is a better fit for a public API. However, using Ext.Direct as an router between your REST interface and your ExtJS frontend makes sense...

    Quote Originally Posted by misha View Post
    You gave batching as main reason for using direct. But isn't batching possible with REST approach too?

    I can set autoSave to false on my restful store, and call save() by hand, so all changes to the store will be submitted in one call as opposed to multiple calls if autoSave is true, right?
    ... because HTTP request batching is not possible with REST. It's quite a core concept of REST that each resource has a unique URI. If you want to update user 1 and user 2 you have to POST to /my/RESTful/interface/user/1 and /my/RESTful/interface/user/2. That are 2 HTTP requests and you cannot batch them into one. If you did that it wouldn't be REST anymore.

    If you call save() on a batchSave:true, restful:true store, it will generate multiple HTTP requests. One for each updated/newly created/deleted record. Calling save() on a Ext.Direct enabled store with batchSave:true only generates one HTTP request regardless of how many updated, new or deleted records are in that store.
    Daniel Jagszent
    dɐɳiel@ʝɐgszeɳt.de <- convert to plain ASCII to get my email address

  5. #5
    Sencha User
    Join Date
    Dec 2008
    Location
    Lodz, Poland
    Posts
    173
    Vote Rating
    3
    grzegorz.borkowski is on a distinguished road

      0  

    Default


    You can do batching with REST, using WebDAV extensions. See for example HTTP status code 207 created for this purpose.

  6. #6
    Ext JS Premium Member dj's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    576
    Vote Rating
    2
    dj has a spectacular aura about dj has a spectacular aura about dj has a spectacular aura about

      0  

    Default


    Quote Originally Posted by grzegorz.borkowski View Post
    You can do batching with REST, using WebDAV extensions. See for example HTTP status code 207 created for this purpose.
    Do you have more information about this? HTTP status code 207 is a response code. How would one do a request that should return this response code? As far as I understand [1] and [2] one would need one single URL that the request has to go to and you would also need some sort of a router on the server. AFAIK such a router is not part of a REST interface.



    [1] http://www.webdav.org/specs/rfc2518....tatus.response
    [2] http://restpatterns.org/HTTP_Status_...-_Multi-Status
    Daniel Jagszent
    dɐɳiel@ʝɐgszeɳt.de <- convert to plain ASCII to get my email address

  7. #7
    Ext User
    Join Date
    Jun 2009
    Posts
    5
    Vote Rating
    0
    mnovakovic is on a distinguished road

      0  

    Default


    I guess that we all agree on that any good application should have some kind of API exposed over REST, which is currently widely accepted "standard" (not to say that is ql).

    So if i need to use REST for this purpose why should i use Direct and how should i use it because i would then need 2 points of access for clients which can be hard to maintain at some point...

  8. #8
    Ext JS Premium Member dj's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    576
    Vote Rating
    2
    dj has a spectacular aura about dj has a spectacular aura about dj has a spectacular aura about

      0  

    Default


    Quote Originally Posted by mnovakovic View Post
    So if i need to use REST for this purpose why should i use Direct and how should i use it because i would then need 2 points of access for clients which can be hard to maintain at some point...
    Yes, you would have two different access vectors but that does not have to mean that you have to maintain these two independently. It should be fairly easy to add Ext.Direct's router as a (fairly transparent) layer between the RESTful interface of your application and your client side javascript. So you only have to maintain the RESTful interface. Nevertheless it is added complexity but it also brings you added benefits. Consider what's more important in your case.


    PS: Ext.Direct and Ext.Direct's RemotingProvider are not the same. Batching requests is a feature of the RemotingProvider. Ext.Direct is a quite abstract thingy; Comet/Polling provider for it are in the works, a REST provider would be easy to do. So whenever I praise the benefits of Ext.Direct I actually mean the benefits of its remoting provider.
    Daniel Jagszent
    dɐɳiel@ʝɐgszeɳt.de <- convert to plain ASCII to get my email address

  9. #9
    Ext User
    Join Date
    May 2008
    Posts
    21
    Vote Rating
    0
    Nalfein is on a distinguished road

      0  

    Default


    Quote Originally Posted by misha View Post
    Are there any drawbacks in using direct btw?
    You lose simplicity, browser caching and scalability.

    The argument with batching request is a red herring in the discussion. REST supports batch requests natively at HTTP level, using persistent connections! All modern browsers support that. All you have to do is to send appropriate headers.

    When you make proper use of browser caching you will gain another boost in performance.

    I don't know why Ext's creators decided to use a RPC solution. It is a step back.

  10. #10
    Ext JS Premium Member dj's Avatar
    Join Date
    Mar 2007
    Location
    Germany
    Posts
    576
    Vote Rating
    2
    dj has a spectacular aura about dj has a spectacular aura about dj has a spectacular aura about

      0  

    Default


    Quote Originally Posted by Nalfein View Post
    You lose simplicity, browser caching and scalability.
    Simplicity and browser caching I understand and I (at least with browser caching) agree with. Could you elaborate on why one would loose scalability?

    Quote Originally Posted by Nalfein View Post
    The argument with batching request is a red herring in the discussion. REST supports batch requests natively at HTTP level, using persistent connections! All modern browsers support that. All you have to do is to send appropriate headers.
    Persistent connections are a bit ambiguous in this domain so to clarify that we are talking about the same thing: HTTP 1.1 Persistent Connections: keeping the TCP connection open after one HTTP request finished so that further HTTP requests can be made without the overhead of establishing a TCP Connection first. Header involved Connection: keep-alive and Keep-Alive: 123.

    You are right modern browser support that and automatically set these header for XHRs. That's great because the TCP connection does not need to be reestablished for every XHR. But sending multiple XHRs as opposed to only one batched XHR is nevertheless slower because: (a) of the added HTTP overhead (Header, HTTP roundtrip) (b) even modern browser only support 2 or 6 parallel TCP connections to one domain. Pipelining the requests through available TCP connections brings another overhead. (c) Content encoding algorithms (i.e. gzip/deflate) can only see and process the individual response. That's not as efficient as gzip'ing the batched response (one dictionary, synergy effects).

    I cannot quantify the overhead of (a), (b) and (c) but I did see a significant speed improvement after implementing Ext.Direct's RemotingProvider in one of my apps so I assume that it is significant.
    Daniel Jagszent
    dɐɳiel@ʝɐgszeɳt.de <- convert to plain ASCII to get my email address

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar