Because experience
is the only teacher

Kata12: Best Sellers

A GedankenKata this week: no code needed (although writing short prototypes might help you come to a conclusion).

Say you’re writing code for a high-colume online site that sells things (something like Amazon). Your site is wildly popular, and you sell millions of items each day.

The marketing department wants the home page to display a top-ten list of the best selling items over the last 24 hours, with the list being updated each hour.

How would you implement this?

  • Are there any changes you could ask for to make the implementation easier?

  • What would be the impact if they later came back and said:

    • only update the list once per day; or
    • we need the list updated in real time: each time the home page is displayed we need the list to reflect the 24 hours up until that point.

This kata might be deeper than it first appears. You might want to consider database vs. in-memory solutions, data structures that allow aging, time-space tradeoffs, and the like.