Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
Markdown Monster - The Markdown Editor for Windows

The problem with posting demos...


:P
On this page:

Last night I posted an AJAX demo of my Specials Sorter for my store for people to check out. Well, it turns out that doing that wasn’t the most optimal idea as people started playing with the sorter simultaneously. Tim Haines sent me a note saying that while it worked the items were bouncing around a bit at random.

 

Of course he’s right – not because the code is bad, but because the sorter assumes it’s the only person sorting at a time. In a real life use case a Store Administrator would be managing items very rarely and certainly there wouldn’t be more than one person doing this at a time.

 

Looking at the logs, a lot of people have actually hit the site earlier this morning and were playing with it. Simultaneous updates by multiple will result in sorts that are not yielding the proper sort orders as multiple people are rearranging items at the same time. Oooops… so much for a cool demo <g>.

 

Another problem with demos is that inevitably there will be some smart ass, who will use the most destructive option and deletes all items from the list. So then the form comes up empty. It’s easy to add items back in, but it looks like a broken demo right from the start – adding is a little more involved especially if you add specials from scratch by writing text.

 

Interesting point on that count too – in the West Wind Web Store I use a DemoMode flag that determines whether options are available. I can also do this in the client script but it looks a bit more ugly:

 

function SaveOrder(Pk,Order)

{

<% if (Westwind.WebStore.App.Configuration.DemoMode) { %>

    if (Order == 0)

    {

        alert("Deletion of Specials is not supported in the demo version.");

        return;

    }

<% } %>

   

    var Special = LoadRow(Pk);

    if (Special)

    {

        Special.Special = Order;

 

        SaveItem(Pk);

        Callback.ResortSpecials(); // Resort items

        LastSelection = Pk;

        LoadSpecialsTable();  // reload table so it sorts       

    }

}

 

For now this will do – I probably will pull this out once the dust settles around this feature, but for now this should keep the more destructive folks at bay from killing the demo.


The Voices of Reason


 

Rick Strahl's Web Log
October 24, 2006

# Building an AJAX based Specials Sorter - Rick Strahl's Web Log

In light of Tim Haines BlogConversation on AJAX uses in Web Store situations I built sorter for Specials that display on the main page of the store. Here are few thoughts on the process and the results...

West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024