One would expect developers to be able to write something like the piece of code below:
// we'll use the order-tracking store using(OrderTracking orderTracking = new OrderTracking()) { // find all the pending orders for sales people // in Washington var orders = from order in orderTracking.SalesOrders where order.Status == "Pending Stock Verification" && order.SalesPerson.State == "WA" select order; foreach(SalesOrder order in orders) { // obtain a list of StockAppProduct objects // to be used for validation ListThere are two elements that are important to highlight in the code above:products = new List ( from orderLine in order.Lines select new StockAppProduct { ProductID = orderLine.Product.ID, LocatorCode = ComputeLocatorCode(orderLine.Product) } ); // make sure all products for this order // are in stock through the stock management // system if(StockApp.CheckAvailability(products)) { // mark the order as "shippable" order.Status = "Shippable"; } } // if we marked one or more orders as shippable, persist // the changes in the store orderTracking.SaveChanges(); }
- No artificial constructs. It's common to see applications that need to adapt to peculiarities of the underlying store schema. For example, applications built on top of relational databases often have to make extensive use of joins in order to navigate through relationships. In the code above, in contrast, the "shape" of the data follows the abstractions of the problem being modeled; there are "orders", which have "order lines" and that are related to a "sales person".
- No plumbing. The code is very database intensive, yet there are no database connection objects, no external language such as SQL for query formulation, no parameter binding, no configuration embedded in code. In this sense, you could say this code is "pure business logic".
The rest of this paper describes in detail the various elements that work together in order to make the sample above work.
No comments:
Post a Comment