2008年5月12日星期一

Dynamic effective price control with Decorator

There’s an interesting consequence of eCommerce on the Web: when companies use localised prices for different regions, it becomes transparently obvious that living in the UK (and the EU in general) is much more expensive than living in the US. So when I was looking at buying some software recently – available via download, involving no retail outlets or shipping – I was somewhat shocked by the price differential that we have to pay on our side of the pond. Of course, when calculating prices online, retailers often have to allow for many other factors such as local taxation rates, discounts for customers that are upgrading their software, promotional offers and reduced prices for educational customers. So I began to wonder how I might choose to implement a flexible pricing strategy in, say, an ASP.NET application. This article describes one approach using a standard Gang of Four (GoF) Design Pattern Extract Product . The important thing to note about this table is that the prices are held exclusively in US$. The code that reads the values from this table is not relevant to our discussion (and won’t be examined in this article). Suffice to say that an objective for the model is that we only need to maintain one product price table; not one per country. We now need some form of “shopping cart” object to hold the customers’ order information. Again, this code is kept deliberately simple as it’s not the focus of the article, so we have two classe .

没有评论: