Friday 26 November 2010

hiJump - Why CQS?

One of the most important aims of hiJump was to try to deal with the issue of communication between the browser and the server. We will have all come across the following pattern of communication:
  1. Browser requests page from server (get request, full page refresh)
  2. User fills in form
  3. Browser posts data to server (post request, full page refresh)
  4. Server finds issue with data and returns same page as the get request in step 1 but with a message describing the problem
Now this is very standard but not very nice. Why is it not nice? Well you have 'gets' returning html and you have 'posts' sending data (in effect a command) which also returns html. Yuck.

Now this sequence just about hangs together in an html interface which is not ajax based but it starts to cause real problems in an RIA (Rich Internet Application - AJAX based UI to you and me).

Take a look at this example of flow in an RIA:
  1. User clicks on a button to open a modal window (we are talking jquery modal here)
  2. An ajax get request is sent from the server for the content of the modal window and it is displayed
  3. The user fills in the form and clicks OK
  4. An ajax post is sent to the server
  5. The popup is closed
..... What happens if there is an error\validation error on the server??? This is the crux of the problem. If we are rendering html from our post requests, the return from our post needs to tell the UI to either close the popup (succeeded) or render the return from the post containing the form and the message back into the popup (failed). This is hard, horrible, non-consistent, non-intuitive stuff and you can imagine how easily this is abused over time in the code.

So, instead of posts ever returning html, they alway returns a json object containing only the following data:
  • Success\Fail flag
  • List of failure reasons if fail
  • Id of generated entity if success and the post asked to create something
  • List of domain events on the server which were fired during the execution of the command
If there is a failure: the UI can handle it in a consistent way providing a nicely formatted list of reasons in a modal window and stop execution at this point.

If it is a success: the UI can show the list of things that happened and can continue on its way and close the modal window. Or in the case of a 'create' can go ahead and load some more html using the ID returned

This works out quite nicely for the following reasons:
  • You do not have to do the old 'viewstate' type work of making sure people do not lose what they have entered if there has been an error. What they entered is still sat there and they can edit it and try to press the button again
  • The UI is controlling the application flow not a combination of the UI and the server post responses
  • All browser\server communication can go through this consistent process leading to much greater consistency in the code
In my next post I will be running through some fundamental requirements around domain modeling etc needed to make this work

7 comments:

  1. Really the blogging is spreading its wings rapidly. Your write up is a fine example of this.It also cleared my doubt on using Rich Internet Application.
    sap support pack upgrade

    ReplyDelete
  2. ERX Pro Some women and especially women are hesitant to Enhance Muscle Supplement. They fear which are adding bulk. Some think your kids make them more manly. Interestingly the actual reason being not possible because women lack the appropriate testosterone at high volumes. https://www.healthsupreviews.com/erx-pro-male-enhancement/

    ReplyDelete
  3. There is more to it than just Weight Loss. Weight Loss is in the eye of the beholder. Ultra Thin Keto Weight Loss worked beautifully. There are many lasting conclusions on this wave length. I, indeed, do know a lot in the matter of Weight Loss. With regards to Weight Loss, a lot is said about the importance of Weight Loss. I'm going to give you with these things as long as I have been wondering how to leverage it for my Weight Loss. Why do typical people trip into that trap?

    https://www.nutramini.com/ultra-thin-keto/

    https://www.nutramini.com/keto-prime-diet/

    https://www.nutramini.com/ketophin/

    http://latestreviews.over-blog.com/drone-blade-720

    http://nutragrow.over-blog.com/detox-herb-thuoc/

    https://nutramini.blogspot.com/2019/12/ultra-thin-keto.html

    ReplyDelete
  4. Blend nut butter into a smoothie, add nuts or drizzle nut butter into overnight oats, sprinkle nuts onto salads, cooked veggies, and stir fries, snack on nuts as is or combined with fruit. You can even whip up a batch of energy balls by combining nut butter and chopped nuts with add-ins like oats, cinnamon, minced dried fruit, and chopped dark chocolate.

    https://www.nutriminimart.com/keto-body-trim-reviews/

    https://www.nutriminimart.com/one-shot-keto-pro/
    https://www.nutriminimart.com/keto-slender/
    https://www.nutriminimart.com/xtremax-reviews/
    https://www.nutriminimart.com/vital-lean-keto-reviews/
    https://www.nutriminimart.com/keto-complete-diet/
    https://www.nutriminimart.com/wunder-diat-keto-de/
    https://www.nutriminimart.com/ultraketo-advanced-bewertungen/
    https://www.nutriminimart.com/keto-advanced-1500/

    ReplyDelete
  5. You must make sure that you keep your spot. We're far from them on that topic. Well, why does the Ketosis Diet Pills industry even exist? Nevertheless, always remember to match your abilities to the needed procedures for Ketosis Diet Pills. I'll need to give you credit. Let's not keep that masked any longer. Have you ever noticed Ketosis Diet Pills before? Here's the 'pro' side of the argument.


    https://www.supplementz.org/best-health-keto-reviews-uk/

    https://www.supplementz.org/trim-life-keto/
    https://www.supplementz.org/optimal-max-keto/
    https://www.supplementz.org/veromin-cbd-gummies/
    https://www.supplementz.org/mens-miracle-health/
    https://www.supplementz.org/pure-balance-cbd-gummies/

    ReplyDelete
  6. Usually these symptoms start within 36 hours of stopping the drug, and last for a couple of weeks. Because these symptoms can last several weeks or longer, long-term replacement drugs given by a clinician may be given in order to help symptoms. Benzodiazepines – which are used to treat anxiety, insomnia, and seizures – are often given to the patient in a clinical setting to alleviate their withdrawal symptoms.

    https://www.offerplox.com/cbd-products/condor-cbd-gummies/

    https://www.offerplox.com/weight-loss/nucentix-keto-x3/
    https://www.offerplox.com/weight-loss/oprah-winfrey-gummies/
    https://www.offerplox.com/weight-loss/pure-kana-keto-gummies/
    https://www.offerplox.com/cbd-products/ree-drummond-cbd-gummies/
    https://www.offerplox.com/wellness/glucotrust-reviews/
    https://www.offerplox.com/weight-loss/exipure-weight-loss/

    ReplyDelete
  7. You know I should sidestep that as much as possible. There are only a few differences that apply. As a matter of fact, it is true apropos to Diet Pills because you won't locate a qualified person for the job. You don't want to have to give up on quality just to get a sensational price on Diet Pills. I gather Diet Pills could be actually cool. It has been detailed by me a while ago. This is a good time to learning with it.

    https://www.offerplox.com/weight-loss/trivexa-reviews/

    https://www.offerplox.com/weight-loss/progenifix-reviews/
    https://www.offerplox.com/skin-care/amarose-skin/
    https://www.offerplox.com/skin-care/skincell-advanced/
    https://www.offerplox.com/cbd-products/proper-cbd-gummies/
    https://www.nutraket.com/lets-keto-gummies/
    https://www.nutraket.com/slim-candy-keto-gummies/
    https://www.claimhealthy.com/lifetime-keto-gummies/
    https://www.claimhealthy.com/power-vigor-me-gummies/

    ReplyDelete