E-commerce options: Product Attributes vs. Master Products
According to DHH's recent comments, I should simply expose CRU and D methods (/product/view/7 or /category/view/12). But I've already decided that four verbs don't a controller API make. So my biggest question is whether to expose my service objects and verbs or whether to add a "feature facade" . . .
The simplest comprehensive model I've been able to come up with for a catalog is four screens: category detail, product detail, search product list and cross sell product list . . .
In this site, the calculation for product price is extremely complex and requires about 30 lines of code. Unfortunately, the client wants product search, product list and product detail pages to display the price. What to do?!
In the bad old days (pre-OO), my search, product list and product detail pages would have all called the same UDF or custom tag. Luckily I have an iterating business object for my product so I can put all of the necessary code into getPrice() and whether I load it up with a single record or a collection, I can still use the same getPrice() method to encapsulate the code to calculate the price.
I would be interested to hear how anyone who uses recordsets for lists and beans for single records would handle this (the calculation is too complex and too likely to change for me to want to put it into the database).
Of course you could put the code into the service layer, looping through the query and updating it before sending it out, but then what do you do with your bean? Do you duplicate the code in the bean and the service (yuck!) or run the bean query through the same transformation before loading it up? And if you do all of the calculations in the service layer and are guaranteeing all of your getters to be dumb, aren’t you losing one of the main benefits of using beans? Why not just return a recordset for single and multiple records?
Input appreciated!!!